O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Frame-based input handling

In all the previous examples, we used property change signal handlers to execute code when the state of the logical device or object picker changes. This allows you, for example, to execute a function at the moment a button is pressed or released. However, sometimes you want to execute a continuous action (for example, accelerate an object) while a button is pressed. This is easy to do with just a few changes to the code.

First, you need to attach an id to the object with interesting properties (for example Action, Axis, or ObjectPicker):

LogicalDevice {    actions: [        Action {            id: myAction            inputs: ActionInput {                sourceDevice: keyboardDevice                buttons: [Qt.Key_A]            }        }    ]}

This will allow you to refer to its properties. Next, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required