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

Keyboard and mouse buttons

An action is represented by the Action type. An action can be triggered by pressing a single key, a key combination, or a key sequence. This is defined by the inputs property of the Action type. The most simple kind of input is ActionInput which reacts to a single key.

When the action is triggered, its active property will change from false to true. When the corresponding key or key combination is released, active changes back to false. You can use the usual QML features to track changes of the property:

Entity {    //...    KeyboardDevice { id: keyboardDevice }    MouseDevice { id: mouseDevice }    LogicalDevice {        actions: [            Action {                inputs: ActionInput {                    sourceDevice: keyboardDevice                    buttons: [Qt.Key_A]                } onActiveChanged: ...

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