Have a go hero – Practicing key-event propagation

As an exercise, you can expand our last example by building a larger array of items (you can use the Grid element to position them) and defining a navigation system that makes use of the KeyNavigation attached property. Have some of the items handle events themselves using the Keys attached property. See what happens when the same key is handled by both mechanisms. Try influencing the behavior using the priority property.

When you set the focus property of an item to true, any previously used item loses focus. This becomes a problem when you try to write a reusable component that needs to set focus to its children. If you add multiple instances of such a component to a single window, their ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.