Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:06:05+00:00 2026-05-30T21:06:05+00:00

I want to take each element within a qstringlist and get the raw data

  • 0

I want to take each element within a qstringlist and get the raw data from the list not whatever pyqt is storing it as.

def find(self):
        self.foundFileList.setRowCount(0)

        fileName = self.inputFileName.currentText()
        path = self.directoryPath.currentText()
        maxSize = Decimal(self.maxFileSize.value())
        i = 0

        self.updateComboBox(self.inputFileName)
        self.updateComboBox(self.directoryPath)
        self.currentDir = QtCore.QDir(path)

        if not fileName:
            fileName = "*"

        allFiles = self.currentDir.entryList([fileName],
            QtCore.QDir.Files | QtCore.QDir.NoSymLinks, QtCore.QDir.Size)

        files = self.currentDir.entryList([fileName],
            QtCore.QDir.Files | QtCore.QDir.NoSymLinks, QtCore.QDir.Size)

        for fn in allFiles:
            file = QtCore.QFile(self.currentDir.absoluteFilePath(fn))
            size = Decimal((QtCore.QFileInfo(file).size() + 1023) / 1024)

            if size > maxSize:
                files.removeAt(i)

            i += 1

        self.showFiles(files)

def showFiles(self, files):
        ##Clean house before new round of files is displayed
        del nameList[0:len(nameList)]
        del fileList[0:len(fileList)]
        i = 0
        for fn in files:
            nameList.append(fn)
            file = QtCore.QFile(self.currentDir.absoluteFilePath(fn))
            fileList.append(file)
            size = QtCore.QFileInfo(file).size()
            ##Some other stuff below here but it's irrelevant

        print nameList
        print "_____________________________"
        print fileList

The output I get from this is as follows:

> [PyQt4.QtCore.QString(u'data - Copy (2).txt'),
> PyQt4.QtCore.QString(u'data - Copy (3).txt'),
> PyQt4.QtCore.QString(u'data - Copy (4).txt'),
> PyQt4.QtCore.QString(u'data - Copy (5).txt'),
> PyQt4.QtCore.QString(u'data - Copy (6).txt'),
> PyQt4.QtCore.QString(u'data - Copy.txt'),
> PyQt4.QtCore.QString(u'data.txt')]
> _____________________________ 
> [<PyQt4.QtCore.QFile object at 0x000000000B28C400>, 
> <PyQt4.QtCore.QFile object at
> 0x000000000B28C598>, <PyQt4.QtCore.QFile object at
> 0x000000000B28C730>, <PyQt4.QtCore.QFile object at
> 0x000000000B28C8C8>, <PyQt4.QtCore.QFile object at
> 0x000000000B28CA60>, <PyQt4.QtCore.QFile object at
> 0x000000000B28CBF8>, <PyQt4.QtCore.QFile object at
> 0x000000000B28CD90>]

As you can see I just get QString values and what appears to be memory locations I want the actual strings by themselves and the actual directory values as strings to store into a python list. The main reason for me doing this is that I have a script for matplotlib and scipy already written and all I need are these two lists to make it work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:06:06+00:00Added an answer on May 30, 2026 at 9:06 pm

    How about:

    print map(str, nameList)
    print "_____________________________"
    print [str(f.fileName()) for f in fileList]
    

    The first one just converts each QString to a string.

    The second gets the fileName() value of each QFile

    You could also write the map as a list comprehension:

    print [str(name) for name in nameList]
    

    I also wanted to add something here to address an issue that may be causing the overall confusion. And that is the difference between the printed representation of a python object and the actual value of the object.

    Any python object can define a __repr__() method which will return a string, to provide a visual printing representation of that object. When you print these objects out, it is the same as calling print repr(myObject). You print a QStringList which contains QStrings. The QStrings printed repr is to show you the module path, and then the enclosed unicode value. The object is still a QString and has all the method of a QString. To see a different printed value, you must convert it to, say, a string object. A string’s repr happens to be simply its own raw string value.

    I wanted to mention this bit in response to your comment, asking if you should go in and delete the PyQt4.QtCore.QString(u bits from each element, suggesting that they were now a string object with junk data. Again, thats only the repr of the QString, being printed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Dictionary data base and I want to return an element from
This should be an absurdly easy task: I want to take each line of
We want to take XML data and convert it to an NSDictionary object, but
I want to take a file from disk and upload it into an Oracle
Take List<Car> . Each Car has a unique index identifying it, say RegNumber and
Problem: I want to get all locations from a database and encase them all
The question says it all - I want to take a list object full
I want to pass the string value which I get from the textarea into
Essentially I want to take a list of things like... a 345 b 762
I have a UL list and I want to change the class of each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.