KeyPress events within a Label
Solved
QML and Qt Quick
-
Hello, I'm working on a QML application, and I have a ToolBar along the bottom of the ApplicationWindow, very similar to the example code. Within that ToolBar are several Labels, and I'd like the text in one of these labels to update when I press the P key. Right now I'm using the following code, lifted from this documentation page
The code is:
Label { id: LockLabel focus: true Keys.enabled: true Keys.onPressed:{ console.log("keypress") if(event.key == Qt.Key_P){ pitchLockLabel.text = " Lock" console.log("lock") event.accepted = true } }
My code does not appear to even register the "keypress" console output when P is pressed. My belief is that this is due to how I've got the Keys type set up, but I'm really quite new to QML and I'd like some insight into that. Any help would be appreciated!
twall.