QML Mouse onReleased Happening before onClicked(Solved)
-
Below is my code, what I want to do is change color of button while clicking and releasing button.
But it seems that onReleased Happening before onClicked when I print to console.@MouseArea{ anchors.fill: parent onClicked:{ console.log("onClicked") //Change button color here } onReleased: { console.log("onReleased") //Change button color here to another } }
@
Console output
@qml: onReleased
qml: onClicked@ -
Hi,
According to "clicked":http://qt-project.org/doc/qt-5/qml-qtquick-mousearea.html#clicked-signal, release will first be fired and then click. So a better way would be to use pressed.
-
You need to use onPressed instead of onClicked.
-
bq. but how can I get unclick event?
Sorry, didn't understand unclick event. Can you explain ? Won't onPressed be helpful to your scenario ?
-
You must use onPressed or don't use onReleased when using onClicked.