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

Windows/native file dialog: If no filters are passed to QFileDialog::getSaveFileName(), it shows an empty filter

    XMLWordPrintable

Details

    • fc6d5ed18da29138494803baa11c0edc22ace7f4 (qtbase/5.7, 22.2.2016, 5.7)

    Description

      In case one calls QFileDialog::getSaveFileName() without any parameters, it shows an empty filter on Windows, which looks a bit odd. The issue isn't reproducing on Linux.

      The attached code snippet can be used to reproduce the issue:

      #include <QApplication>
      #include <QFileDialog>
      
      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
          QFileDialog::getSaveFileName();
          return 0;
      }
      

      If this is intended behaviour then it should be documented at least.

      The patch here:

      --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
      +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
      @@ -1646,6 +1646,8 @@ QWindowsNativeDialogBase *QWindowsFileDialogHelper::createNativeDialog()
           const QStringList nameFilters = opts->nameFilters();
           if (!nameFilters.isEmpty())
               result->setNameFilters(nameFilters);
      +    else
      +        result->setNameFilters(QStringList() << QLatin1String("All Files (*.*)"));
           if (opts->isLabelExplicitlySet(QFileDialogOptions::FileName))
               result->setLabelText(QFileDialogOptions::FileName, opts->labelText(QFileDialogOptions::FileName));
           if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
      

      can be used to workaround the problem. Doing it that way it shows all files in case no filters are set.

      Attachments

        1. qtbug50644_diag.diff
          0.6 kB
        2. qtbug50644_qml.zip
          8 kB
        3. qtbug50644.zip
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            mipohjan Milla Pohjanheimo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes