Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38985

QFileDialog signal fileSelected emitted twice on one user choice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.2.1
    • None
    • Ubuntu 14.04, Qt5.2.1 (as distributed), PyQt5.2.1, Python 2.7 or 3.4 (doesn't make a difference.)

      User types ‘foo’ into a QFileDialog for choosing a Save file name, and clicks the OK button. App receives fileSelected signal twice, once with filename param “foo” and second with param “foo.txt”. Qt should only send signal once with foo.txt. (dialog.setDefaultSuffix(“txt”) was called on the dialog.)

      In my experience, this is new behaviour. On earlier Ubuntu 13.04 and Qt4.8 I don't remember this (although it might be that I just didn't see it.)

      A workaround is to just use the dialog's accepted signal, and query the filename via QFileDialog.filesSelected() (a getter, not a signal) which only returns 'foo.txt'.

      Small demo program in PyQt attached, which prints to the console when signal is received (twice.)

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            bootchk lloyd konneker
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes