June 2019
Intermediate to advanced
348 pages
8h 28m
English
QPixmap is a class that's provided by the Qt library, and it is intended to be used when we need to display images on a screen. That's exactly how we used it in our project—we read an image in as an instance of it and added the instance to QGraphicsSence to display it.
There are many ways to create instances of QPixmap. Like we did in Chapter 1, Building an Image Viewer, and the previous sections of this chapter, we can instantiate it with the path of an image file:
QPixmap map("/path/to/image.png");
Alternatively, we can instantiate an empty QPixmap and then load data into it afterward:
QPixmap map; map.load("/path/to/image.png");
With an instance holding an image in it, we can save the image in it to a file by calling its save ...
Read now
Unlock full access