Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access