Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.9
-
None
-
macOS 10.11.6
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(); }