from PyQt4.QtGui import QPixmap, QPainter pixmap = QPixmap('image.png') painter = QPainter(self) painter.drawPixmap(0, 0, pixmap)
from PyQt4.QtGui import QPixmap, QPainter pixmap = QPixmap(100, 100) painter = QPainter(pixmap) painter.drawEllipse(0, 0, 99, 99) painter.end() pixmap.save('circle.png')In this example, we are creating a QPixmap object of size 100x100 pixels. We then create a QPainter object and specify the pixmap as the surface to paint on using the "pixmap" parameter. We draw an ellipse on the QPainter surface using the drawEllipse function. Finally, we end the painting operation with the end function and save the resulting pixmap to a file named 'circle.png'. The package library for this code is PyQt4.QtGui.