Qt 4.8
|
The KeyNavigation attached property supports key navigation by arrow keys. More...
The KeyNavigation attached property supports key navigation by arrow keys.
Key-based user interfaces commonly allow the use of arrow keys to navigate between focusable items. The KeyNavigation attached property enables this behavior by providing a convenient way to specify the item that should gain focus when an arrow or tab key is pressed.
The following example provides key navigation for a 2x2 grid of items:
The top-left item initially receives focus by setting Item::focus to true
. When an arrow key is pressed, the focus will move to the appropriate item, as defined by the value that has been set for the KeyNavigation left , right , up or down properties.
Note that if a KeyNavigation attached property receives the key press and release events for a requested arrow or tab key, the event is accepted and does not propagate any further.
By default, KeyNavigation receives key events after the item to which it is attached. If the item accepts the key event, the KeyNavigation attached property will not receive an event for that key. Setting the priority property to KeyNavigation.BeforeItem
allows the event to be used for key navigation before the item, rather than after.
If item to which the focus is switching is not enabled or visible, an attempt will be made to skip this item and focus on the next. This is possible if there are a chain of items with the same KeyNavigation handler. If multiple items in a row are not enabled or visible, they will also be skipped.