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

File Dialog currentFolder changes are not respected on dialog reopen on Mac

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.3.1
    • Quick: Dialogs
    • None
    • MacOS Monterey 12.5, XCode 13.4.1
    • macOS

    Description

      If I will create a FileDialog and set its currentFolder property, the dialog will navigate to it just on the first open. If I change that property between subsequent reopens the changes to this property are ignored on Mac (works fine on Windows). I am pretty sure it is not a new issue and I have seen that in the Qt 5.x series.

      Quick temporary workaround is to patch the QQuickFileDialog as below, but I suspect it should be fixed in the Cocoa platform file dialog helper.

      void QQuickFileDialog::setCurrentFolder(const QUrl &currentFolder)
      {
        qCDebug(lcFileDialog) << "setCurrentFolder called with" << currentFolder;
        if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) {
      #if !defined(Q_OS_MACOS)
          fileDialog->setDirectory(currentFolder);
      #else
          if (isVisible()) {
            fileDialog->setDirectory(currentFolder);
          }
          else {
            // Recreate the native dialog to ensure that the new current folder is applied
            // as its changes seem to be ignored on subsequent reopens by Cocoa/QPlatform
            destroy();
          }
      #endif
        }
        m_options->setInitialDirectory(currentFolder);
      }

      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
            dariusz.maciejewski Dariusz Maciejewski
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes