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

Handling user input

The first way of receiving events in Qt 3D is to use Qt GUI capabilities. The Qt3DQuickWindow class we use inherits from QWindow. That allows you to subclass Qt3DQuickWindow and reimplement some of its virtual functions, such as keyPressEvent() or mouseMoveEvent(). You are already familiar with this part of Qt API because it's roughly the same as provided by Qt Widgets and Graphics View. Qt 3D doesn't introduce anything special here, so we won't give this approach much attention.

Similar to Qt Quick, Qt 3D introduces a higher-level API for receiving input events. Let's see how we can use it.

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