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

macOS native QFileDialog stacks above other active applications if opened without exec

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9
    • None
    • macOS 10.11.6
    • macOS

    Description

      If a QFileDialog is opened using show or open then the native macOS panel stacks above other application windows when the Qt application is not active.

      In the attached example the widget has two buttons. One opening a QFileDialog using the exec method. The file dialog correctly stacks behind active application. The second opens a non modal QFileDialog using show. In this case the file dialog stacks in front of the active application.

       

      #include <QApplication>
      #include <QFileDialog>
      #include <QWidget>
      #include <QVBoxLayout>
      #include <QPushButton>
      
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QWidget * widget = new QWidget();
          QVBoxLayout * layout = new QVBoxLayout();
          QPushButton * button = new QPushButton("exec()");
          button->setToolTip("Open a QFileDialog using exec()");
          button->connect(
              button, &QPushButton::clicked,[widget] {
              QFileDialog * dialog = new QFileDialog(widget);
              dialog->setWindowModality(Qt::ApplicationModal);
              dialog->exec();
          });
          layout->addWidget(button);
          button = new QPushButton("show()");
          button->setToolTip("Open a QFileDialog using show()");
          button->connect(
              button, &QPushButton::clicked, [widget] {
              QFileDialog * dialog = new QFileDialog(widget);
              dialog->setWindowModality(Qt::NonModal);
              dialog->show();
          });
          layout->addWidget(button);
      
          widget->setLayout(layout);
          widget->show();
          return a.exec();
      }
      

      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
            aleserjavec Ales Erjavec
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes