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

Unable to close Modal + Non Dim Popup QML using QQuickWidget using default close policy

    XMLWordPrintable

Details

    Description

      Running the following code:

      Main.cpp: 

      int main(int argc, char* argv[])
      {
         QApplication app(argc, argv);
      
         QQmlEngine engine;
         QMainWindow window;
         QQuickWidget widget(&engine, nullptr);
      
         widget.setSource(QUrl("qrc:///ui/Main.qml"));
      
         if (!widget.errors().isEmpty())
         {
            return EXIT_FAILURE;
         }
      
         widget.setResizeMode(QQuickWidget::ResizeMode::SizeRootObjectToView);
      
         window.setCentralWidget(&widget);
         window.setMinimumSize(1080, 760);
         window.setVisible(true);
      
         return app.exec();
      }

      Main.qml: 

      import QtQuick 2.10
      import QtQuick.Controls 2.3
      
      Item {
         id: root
      
          width: 640
          height: 480
          visible: true
      
         Rectangle {
            width: parent.width / 2
            height: parent.height / 2
            anchors.centerIn: parent
            color: "red"
      
            MouseArea {
               anchors.fill: parent
               onClicked: popup.open()
            }
         }
      
          Popup {
            id: popup
      
            x: Math.round((parent.width - width) / 2)
            y: Math.round((parent.height - height) / 2)
            width: parent.width / 4
            height: parent.height / 4
            modal: true
            dim: false
         }
      }

      Will give you a window with a red box on the middle. Clicking on the red box will trigger a white popup window to appear. Clicking outside of the popup window should close the popup, however because it is within a QQuickWidget, it fails to close.

      Altering the Main.cpp to:

      int main(int argc, char* argv[])
      {
         QGuiApplication app(argc, argv);
      
         QQuickView view;
         view.setSource(QUrl("qrc:///ui/Main.qml"));
      
         if (!view.errors().isEmpty())
         {
            return EXIT_FAILURE;
         }
      
         view.show();
      
         return app.exec();
      }

      Will cause it to work as expected.

       

       

       

      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
            rodrigor Rodrigo Reichert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes