Qt 4.8
|
The Keys attached property provides key handling to Items. More...
The Keys attached property provides key handling to Items.
All visual primitives support key handling via the Keys attached property. Keys can be handled via the onPressed and onReleased signal properties.
The signal properties have a KeyEvent parameter, named event which contains details of the event. If a key is handled event.accepted should be set to true to prevent the event from propagating up the item hierarchy.
The following example shows how the general onPressed handler can be used to test for a certain key; in this case, the left cursor key:
Some keys may alternatively be handled via specific signal properties, for example onSelectPressed. These handlers automatically set event.accepted to true.
See Qt.Key for the list of keyboard codes.
The Keys attached property can be configured to handle key events before or after the item it is attached to. This makes it possible to intercept events in order to override an item's default behavior, or act as a fallback for keys not handled by the item.
If priority is Keys.BeforeItem (default) the order of key event processing is:
forwardTo
If priority is Keys.AfterItem the order of key event processing is:
forwardTo
If the event is accepted during any of the above steps, key propagation stops.