[PyQt] QFileDialog.getSaveFileName returns a tuple, but should return a string

Florian Bruhin me at the-compiler.org
Tue Aug 1 16:41:23 BST 2017


On Tue, Aug 01, 2017 at 03:28:52PM +0000, Webster, Jeremy David wrote:
> A minor inconvenience I think, but the documentation for
> QFileDialog.getSaveFileName shows it should return the filename as a
> string, but it returns a tuple that consists of the filename string
> and the filter

That's intended. In Qt/C++, QString's are mutable, so getOpenFileNames
can set selectedFilter to the filter the user selected.

In Python, strings are immutable, so it returns a tuple instead.

It's one of the rare cases where the Python signature doesn't map 1:1 to
the C++ one.

Florian

-- 
https://www.qutebrowser.org  | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170801/011b3a3c/attachment.sig>


More information about the PyQt mailing list