What just happened?

The preceding code simply adds a signal handler for the gamepadConnected signal of the GamepadManager object. The usual way to add a signal handler is to declare it directly in the section of the sender. However, we can't do that in this case, since GamepadManager is an existing global object that is not part of our QML object tree. Thus, we use the Connections QML type that allows us to specify an arbitrary sender (using the target property) and attach a signal handler to it. You can think of Connections as a declarative version of QObject::connect calls.

The initialization is done, so we can now use the gamepad object to request information about the gamepad input. There are two ways to do that.

First, we can use property ...

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.