[PyQt] QFileDialog.getOpenFileName returns a tuple?

David Cortesi davecortesi at gmail.com
Sat Mar 22 18:05:13 GMT 2014


In converting a PyQt4 program to PyQt5 I ran into an error because under
PyQt5 (5.2), QFileDialog.getOpenFileName() returns a tuple of two strings.
The first is either a path or null depending on the Cancel button, and the
second always null.

According to the C++ doc for getOpenFileName [1], the returned value is a
string, and "If the user presses Cancel, it returns a null string." In the
PyQt4 doc [2] it shows getOpenFileName returning a string (although it
mentions that the three get...Filter methods return tuples).

Was the behavior of getOpenFileName changed deliberately or is this a bug?

Thanks,
Dave Cortesi

[1] http://qt-project.org/doc/qt-5/qfiledialog.html#getOpenFileName
[2] http://pyqt.sourceforge.net/Docs/PyQt4/python_v3.html#qfiledialog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140322/a67cd892/attachment.html>


More information about the PyQt mailing list