Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
Painting
Painting images in its basic form is as simple as calling drawImage() or drawPixmap() from the QPainter API. There are different variants of the two methods, but, basically, all of them allow one to specify which portion of a given image or pixmap is to be drawn and where. It is worth noting that painting pixmaps is preferred to painting images, as an image has to first be converted into a pixmap before it can be drawn.
If you have a lot of pixmaps to draw, a class called QPixmapCache may come in handy. It provides an application-wide cache for pixmaps. Using it, you can speed up pixmap loading while introducing a cap on memory usage.
Finally, if you just want to show a pixmap as a separate widget, you can use QLabel. This widget ...
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