import QtQuick import QtQuick.Controls Window { id: window property int aNumber: 0 width: 640 height: 480 visible: true title: qsTr("Hello World") property bool isClicked: false color: isClicked ? "blue" : "red" MouseArea { anchors.fill: window // Toggle the boolean value onClicked: isClicked = !isClicked } Column { width: 125 height: 75 anchors.top: parent.top Label{ text: aNumber } } Column { id: column width: 125 height: 75 anchors.centerIn: parent TextField{ id: textField placeholderText: "Enter some text" } TextField{ id: textField2 placeholderText: "Enter some text" } Button { id: button text: "Click to open pop up" onClicked: { if(textField.text == textField2.text){ myPopup.open() } else{ myPopup2.open() } } } } Popup { id: myPopup anchors.centerIn: parent width: 150 height: 75 closePolicy: "CloseOnEscape" Column { anchors.centerIn: parent spacing: 10 Text { text: textField.text } Button{ id: button2 text: "close" width: 100 height: 50 onClicked :{ /* button2.x = Math.random() * (window.width - button2.width) button2.y = Math.random() * (window.height - button2.height)*/ aNumber = aNumber + 1 if (aNumber == 3){ myPopup.close() aNumber = 0 } } } } Popup { id: myPopup2 anchors.centerIn: parent width: 150 height: 75 closePolicy: "CloseOnEscape" Column { anchors.centerIn: parent spacing: 10 Text { text: "wrong!" } Button{ text: "close" width: 100 onClicked :{ myPopup2.close() } } } } } }