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

Time for action – Self-updating car dashboard

We will start with the C++ part. Set up a new Qt Quick application. This will generate the main function for you that instantiates QGuiApplication   and  QQmlApplicationEngine and sets them up to load a QML document.

Use the File menu to create New file or Project and create a new Qt Designer form class. Call it CarInfo and choose the Widget template. We will use this class for modifying values of different parameters so that we may observe how they influence what the Qt Quick scene displays. In the class declaration, add the following properties:

class CarInfo : public QWidget { Q_OBJECT Q_PROPERTY(int rpm READ rpm NOTIFY rpmChanged) Q_PROPERTY(int gear READ gear NOTIFY gearChanged) Q_PROPERTY(int ...

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