View Full Version : qml key shortcuts

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

import Qt 4.7
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?