QPixmap pixmap(100, 100); pixmap.fill(Qt::white); QPainter painter(this); painter.drawPixmap(0, 0, pixmap);
QPixmap pixmap("image.png"); QPainter painter(this); painter.drawPixmap(0, 0, pixmap.scaled(50, 50));In this example, we load an existing image file "image.png" into a QPixmap object. Then we create a new QPainter object and pass in the current widget as an argument. Finally, we use drawPixmap to draw a scaled-down version of the image (50x50) at the top-left corner of the widget. Package Library: Qt Library.