PDA

View Full Version : qml key shortcuts



antialias_forum
22nd December 2010, 15:45
Problem: I would like to give an area a keyboard shortcut like so:


import Qt 4.7
Rectangle{
width: 50; height: 50; color: "red"
focus: true
Keys.onPressed: { if ( event.key == Qt.Key_A) keyEffect() }
function keyEffect() {color = "blue"}
}

I plan on using this type of element in a number of places (some in Columns/Rows/Grids, some in ListViews, etc. with different keyboard shortcuts each). However, when I try this only the last one instantiated ever gets checked since it takes away the focus from the others.

Question: How do I manage it so that all elements get checked when a key has been pressed?