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

QFileDialog::selectFile doesn't work in native file dialog after switching from non-native one

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.11.3
    • None
    • Debian testing with KDE Plasma 5 and Qt installed from Debian repository (Plasma integration with native file pickers doesn't work out-of the box with custom-built qt from dev branch)
    • All

    Description

      'QFileDialog::selectFile()' does not pre-fill the given file name in the native file dialog if the dialog has previously been a non-native one, e.g. for this simplified example:

       

      #include <QApplication>
      #include <QFileDialog>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QFileDialog fileDialog;
          fileDialog.setOption(QFileDialog::DontUseNativeDialog);
          fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
          fileDialog.selectFile("test.txt");
          fileDialog.exec();
      
          return a.exec();
      }
      

      When executing this example on KDE Plasma 5, no text is pre-filled in the "Name" textbox.

      Expected result: The text "test.txt" should be pre-selected for the file name. It does work as expected when leaving out the 'fileDialog.setOption()' calls.

      As far as I can see, the problem is that the call to 'd->usingWidgets()' inside 'QFileDialog::selectFile' (s. [1]) returns true because 'qFileDialogUi' has previously been initialized in the call to 'QFileDialog::setOption(QFileDialog::DontUseNativeDialog)'.

       

      [1] https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=blob;f=src/widgets/dialogs/qfiledialog.cpp;h=eb3479b3e0ef1753bcf7215b377263127398da90;hb=481db443d502c8ebc169b7256cb696428cf02199#l1070

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            michaelweghorn Michael Weghorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes