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

QFileDialog signal fileSelected emitted twice on one user choice

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • 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.)

    Description

      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.)

      Attachments

        1. qtbug38985.zip
          1 kB
          Friedemann Kleint
        2. testFileDialogRepeat.py
          5 kB
          lloyd konneker
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes