I’m sorry if my terminology is wrong or I’m way off, I’m quite new to QML.
I’m looking to make a little GUI with QML to change some database entries. One type of value needs a simple spinner that increments the value with the arrow keys.
The menu is passed a label and an item to get the value from the database:
import QtQuick 1.0
Rectangle
{
property alias label: label.text;
property Item value;
height: 50;
width: parent.width;
Text {
id: label;
// ... other properties
}
Text {
id: value_text;
text: value.get_value();
// ... other properties
}
Keys.onPressed:
{
if (event.key == Qt.Key_Enter) {
event.accepted = true;
value.focus=true;
}
}
}
Getting the value works fine, but I can’t figure out how to give the value Item focus. I figured setting value.focus = true would be enough but I never get into the onPressed() handler of my item:
import QtQuick 1.0
Item
{
property string property_name;
function get_value() ...
Keys.onPressed:
{
if (event.key == Qt.Key_Right) { // decrement value }
if (event.key == Qt.Key_Left) { // increment value }
}
}
↧