How to close a popup window using closePolicy in QML
-
Hi,
I have this popupwindow and I want to close it using closePolicy, when I press ESC on keyboard, it closesPopupWindow { id: Acurve width: 300 height: 120 title: "Test" opacity: 0 visible:false }
I tried to write closPolicy:
but it seems that I need to define this property first as enumeration, but i dont know how?There is something called (Popup.CloseOnEscape) but I am not sure how to implement it
-
@mamoud
what isPopupWindow
is that part oif the normal QML lib ?
I know of thePopup
-item and you can very easily defined the close optionsPopup { id: Acurve width: 300 height: 120 title: "Test" opacity: 0 visible:false closePolicy: Popup.CloseOnEscape }
-
@mamoud
like I said thats for the normal Popup -item, I don't know about PopupWindowexample for a ppopup directly from the docu:
import QtQuick.Window 2.2 import QtQuick.Controls 2.1 ApplicationWindow { id: window width: 400 height: 400 visible: true Button { text: "Open" onClicked: popup.open() } Popup { id: popup x: 100 y: 100 width: 200 height: 300 modal: true focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent } }
https://doc.qt.io/qt-5.11/qml-qtquick-controls2-popup.html#details
-
@J.Hilk said in How to close a popup window using closePolicy in QML:
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Popup { id: adAcurve width: 300 height: 120 title: "Test." opacity: 0 visible:false closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
I tried this but get the same error