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

OpenGL in the Graphics View

As a last optimization, you can take advantage of OpenGL. Instead of using the default viewport based on QWidget, advise Graphics View to use an OpenGL widget:

QGraphicsView view;
view.setViewport(new QOpenGLWidget()); 

This usually improves the rendering performance. However, Graphics View wasn't designed for GPUs and can't use them effectively. There are ways to improve the situation, but that goes beyond the topic and scope of this chapter. You can find more information about OpenGL and Graphics View in the Boxes Qt example as well as in Rødal's article "Accelerate your Widgets with OpenGL", which can be found online at https://doc.qt.io/archives/qq/qq26-openglcanvas.html.

If you want to use a framework designed ...

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