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

[QtQuick.Dialogs/Wayland] Native FileDialog does not respect Qt.ApplicationModal flag

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.5.6, 6.7.2, 6.8.0 Beta2
    • Quick: Dialogs
    • Windows 10 22H2 + MSVC 2022; Ubuntu 22.04 Wayland + GCC 11.4.0 (both XCB and Wayland plugins)

    Description

      QFileDialog respects the "ApplicationModal" flag, but FileDialog does not.

       

      Code
      Widgets version:

      #include <QApplication>
      #include <QPushButton>
      #include <QFileDialog>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QPushButton mainButton("Open QFileDialog");
          mainButton.setWindowTitle("Main Window");
          mainButton.resize(400, 300);
          mainButton.show();
      
          QPushButton otherButton("Other");
          otherButton.setWindowTitle("Other Window");
          otherButton.resize(400, 300);
          otherButton.show();
      
          QObject::connect(&mainButton, &QPushButton::clicked, &app, [&]{
              qDebug("Clicked main button");
              QFileDialog dlg(&mainButton);
              dlg.setWindowModality(Qt::ApplicationModal);
              dlg.exec();
          });
          QObject::connect(&otherButton, &QPushButton::clicked, &app, []{
              qDebug("Clicked other button");
          });
      
          return app.exec();
      }
      

       

      QML version:

      import QtQuick.Controls.Basic
      import QtQuick.Dialogs
      
      ApplicationWindow {
          width: 400
          height: 400
          visible: true
          title: "Main Window"
      
          ApplicationWindow {
              width: 400
              height: 400
              visible: true
              title: "Other Window"
      
              Button {
                  text: "Other"
                  onClicked: console.log("Clicked other button")
              }
          }
      
          Button {
              text: "Open FileDialog"
              onClicked: {
                  console.log("Clicked main button")
                  fileDlg.open()
              }
          }
      
          FileDialog {
              id: fileDlg
              modality: Qt.ApplicationModal
          }
      }
      

       

      Steps to reproduce

      1. Click the main button to open the file dialog
      2. While the file dialog is open, attempt to click on the 2 windows' buttons (check the console output for results)

       

      Expected outcomes (Widgets)
      (Windows and Ubuntu) While the file dialog is open, both of the windows' buttons cannot be clicked

       

      Actual outcomes (QtQuick.Dialogs)
      While the file dialog is open...

      • (Windows) ...the Main button cannot be clicked, but the Other button can be clicked
      • (Ubuntu) ...both the Main button and the Other button can be clicked

      Attachments

        For Gerrit Dashboard: QTBUG-127605
        # Subject Branch Project Status CR V

        Activity

          People

            santhoshkumar Santhosh Kumar Selvaraj
            skoh-qt Sze Howe Koh
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change