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 – Drawing a triangle using Qt and OpenGL

For the first exercise, we will create a subclass of QOpenGLWindow that renders a triangle using simple OpenGL calls. Create a new project, starting with Empty qmake Project from the Other Project group as the template. In the project file, put the following content:

QT = core gui
TARGET = triangle
TEMPLATE = app 
Note that our project does not include Qt Widgets module. Using the QOpenGLWindow approach allows us to remove this unnecessary dependency and make our application more lightweight.

Note that Qt Core and Qt GUI modules are enabled by default, so you don't have to add them to the QT variable, but we prefer to explicitly show that we are using them in our project.

Having the ...

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