[SOLVED] qml and qt: pressing buttons
-
wrote on 21 Jul 2011, 08:16 last edited by
how to receive the "button pressed"'s signal? i would to say this: !http://farm7.static.flickr.com/6004/5960480374_db013832fc_m.jpg()!
-
wrote on 21 Jul 2011, 08:27 last edited by
your question is not clear and link to the image does not work...
-
wrote on 21 Jul 2011, 08:27 last edited by
Use signals & slots. If you using Qt C++, it's easy to connect your signals & slots. If you using QML, i assumed you use your custom button element, so you can:
- In your button's mouseArea, do something when
@onPressed: {}@ - Use connect to make your signal and function's connection.
I think you'd better read how to use signals & slots with QML first :D
- In your button's mouseArea, do something when
-
wrote on 21 Jul 2011, 11:25 last edited by
-
wrote on 21 Jul 2011, 12:03 last edited by
I guess these buttons are Qt::Key_Send, Qt::Key_Menu, and Qt::Key_End
Inside your qml item
@Keys.onPressed: {
if (event.key == Qt.Key_Send) {
console.log("call button pressed");
event.accepted = true;
}
}
@ -
wrote on 21 Jul 2011, 13:13 last edited by
oh it is possible! can someone confirm it, please? an example in qml please?
-
wrote on 21 Jul 2011, 13:15 last edited by
Vijay's "Keys.onPressed" snippet is an example in QML. What more do you need?
-
wrote on 21 Jul 2011, 13:26 last edited by
right, however can someone confirm?
-
wrote on 21 Jul 2011, 13:28 last edited by
It looks reasonable to me... should be easy enough to test.
console.log() is your friend.
-
wrote on 21 Jul 2011, 13:57 last edited by
[quote author="Vijay Bhaska Reddy" date="1311249782"]I guess these buttons are Qt::Key_Send, Qt::Key_Menu, and Qt::Key_End
Inside your qml item
Keys.onPressed: {
if (event.key == Qt.Key_Send) {
console.log("call button pressed");
event.accepted = true;
}
}
[/quote]Also, if you want to recieve keyboard events, make sure this:
@
// Inside your element definition
focus: true
@ -
wrote on 22 Jul 2011, 10:20 last edited by
thank everybody!
5/11