[PyQt] QFileDialog.selectFile highlights wrong files

Luca Fasano lucafasano at interfree.it
Thu Jan 7 17:27:36 GMT 2010

Hi all,
I'm performing some tests using "selectFile" method of QFileDialog. 

I noticed that the dialog shown is positioned in right folder and the
file name in "File name" field is correct too, but in many cases the
file highlighted is not the same of the one in "File name" field. 
So if I press the "Open" button without doing nothing, then
"selectedFiles" returns a wrong file name, i.e. that one highlighted,
which is different from the file in "File name" field.

I hope I was clear. To ensure it following there's a simple example:

from PyQt4 import QtGui

if __name__ == '__main__':
    import sys

    app = QtGui.QApplication(sys.argv)
    dlg = QtGui.QFileDialog()
    for s in dlg.selectedFiles():
        print s

Simply I tried to select "/usr/bin/python" file, but if I press "Open"
button when the dialog is shown, a different file name is printed (in my
case "/usr/bin/sphinx2-allphone", which is wrong).

How can I do? Is it a known behaviour or bug or I missed something?

More information about the PyQt mailing list