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

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 ...

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