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

QFileDialog adds wrong extension

    XMLWordPrintable

    Details

      Description

      The following code demonstrates the behaviour on Windows, on Linux everything is fine.
      When entering a filename with extension, everything is fine, when entering one without extension while having the "all files" filter selected, selectedFiles contains the entered filename with the first extension of the first filter (apart from the "all files" filter) appended. So in case of the example code, a .jpeg is appended.
      This might be related to QTBUG-44641 but does not happen on Linux.

      #include <QApplication>
      #include <QDebug>
      #include <QFileDialog>
      
      int main(int argc, char* argv[])
      {
          QApplication app(argc, argv);
      
          QFileDialog fd;
          fd.setAcceptMode(QFileDialog::AcceptSave);
          fd.setMimeTypeFilters(QStringList() << "application/octet-stream"<< "image/jpeg" << "text/plain");
          if(fd.exec() == QDialog::Accepted)
              qDebug() << fd.selectedFiles() << fd.selectedNameFilter();
      
          return app.exec();
      }
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              mmutz Marc Mutz
              Reporter:
              nath Niels Weber
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes