QPixmap pixmap(":/images/image.png"); // load image from resource file QImage image = pixmap.convertToImage(); // convert QPixmap to QImage
QPixmap pixmap(100, 100); // create a pixmap with size 100x100 pixmap.fill(Qt::blue); // fill pixmap with blue color QImage image = pixmap.convertToImage(); // convert QPixmap to QImageThis code creates a 100x100 pixmap and fills it with blue color. Then it converts the pixmap into a QImage using the convertToImage() function. These examples use the Qt library.