[PyQt] QFileDialog.getOpenFileName returns a tuple?

Phil Thompson phil at riverbankcomputing.com
Sat Mar 22 22:23:07 GMT 2014


On 22-03-2014 6:05 pm, David Cortesi wrote:
> 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?

http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#qfiledialog

Phil


More information about the PyQt mailing list