Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.10.1
-
None
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.