Solved Qml set action dynamically
-
Hi,
I have a mouseArea:MouseArea { id: myMouseArea }
How I can set onClicked action for myMouseArea outside this element? I want to set onClicked action dynamically for myMouseArea e.g. in Component.onCompleted section of my qml file.
-
hi @MartinD ,
You can use connect() fucntion
function fnc(){ console.log("click") } Component.onCompleted:{ ms.clicked.connect(fnc) } Rectangle{ height: 90 width: 90 color: "grey" anchors.centerIn: parent MouseArea{ id:ms anchors.fill: parent } }