PDA

View Full Version : "pressed" and "released" signals for buttons



jpietrzak8
11th June 2015, 19:25
Hello! Question from a QML newbie here. I'm trying to port a Qt Widgets-based app I wrote a while ago to QML, using the Qt Quick controls. One of the UI features the app heavily relies upon is the ability to tell when the user starts pressing a button, and when they finally release that button. Unfortunately, it appears that Qt Quick's "Button (http://doc.qt.io/qt-5/qml-qtquick-controls-button.html)" type only has a "clicked()" signal.

So far as I have been able to tell, there aren't any alternative button-like controls which provide press and release signals. Only the raw "MouseArea (http://doc.qt.io/qt-5/qml-qtquick-mousearea.html)" seems to have this level of detail. So, my question is,

a) Am I missing a more full-featured button control?

b) Can I subclass the Button control somehow to add pressed() and released() signals?

or, what I'm really afraid of:
c) Do I need to create my own customized MouseArea-based QML button object just to get access to pressed() and released() signals?

Thanks!

wysota
11th June 2015, 19:54
Use onPressedChanged handler.

jpietrzak8
11th June 2015, 20:03
Use onPressedChanged handler.

Aha, thank you! I didn't notice that QML properties had implicit signals available. :)