[Qt-qml] Javascript constants not allowed in models
Alexey
kavaj at mail.ru
Tue Jan 4 13:43:42 CET 2011
I tried to create a numeric keyboard and stuck at the following: I want to let every
button handle its own key, so I pass this key through the model:
Repeater {
model: ListModel {
id: model
ListElement { label: "7"; value: "7"; key: Qt.Key_7 }
...
In the button component (delegate) I use this:
Keys.onPressed: {
if (event.key == model.key) {
event.accepted = true;
clicked(model.value);
...
But the point is that it doesn't let me use Qt.Key* constants:
file:///D:/Projects/qmlinterface/Controls/Numpad.qml:25:43: ListElement: cannot use script
for property value
ListElement { label: "7"; value: "7"; key: Qt.Key_7 }
^
I could hardcode key codes as integers, but it's not really portable... What would you
suggest, guys?
More information about the Qt-qml
mailing list