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

What just happened?

When the view needs to display the scene, it calls the paint() function of each visible item and provides three arguments: a QPainter pointer that should be used for painting, a QStyleOptionGraphicsItem pointer that contains painting-related parameters for this item, and an optional QWidget pointer that may point to the currently painted widget. In the implementation of the function, we start with setting a cosmetic pen in the painter so that the line width of our graph is always 1. Next, we calculate the number of points in the graph and save it to the steps variable. Then, we create a variable to store the previous point of the graph and initialize it with the position of the first point of the graph (corresponding to ...

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