Detect mouse click outside the modal window
Unsolved
QML and Qt Quick
-
I have modal dialog where is popup window. Popup is closed when mouse is clicked outside of popup in modal window. But I'd like to close popup also when is clicked anywhere outside the popup. How this can be done?
import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Window 2.1 ApplicationWindow { visible: true width: 640 height: 480 Button { text: "Open modal window" anchors.centerIn: parent onClicked: { modalWindow.show() } } Window { id: modalWindow width: 300 height: 400 modality: Qt.ApplicationModal Rectangle { anchors.fill: parent border.width: 1 MouseArea { anchors.fill: parent onClicked: { popupWindow.show() } } Button { anchors.top: parent.top anchors.right: parent.right text: "Close" onClicked: modalWindow.close() } } Window { id: popupWindow flags: Qt.Popup width: 100 height: 100 x: Screen.width / 2 y: Screen.height / 2 Rectangle { anchors.fill: parent color: "green" } } } }