QPicture picture; QPainter painter; painter.begin(&picture); painter.drawEllipse(50, 50, 50, 50); painter.end(); QPainter widgetPainter(this); widgetPainter.drawPicture(0, 0, picture);
QPicture picture; QPainter painter; painter.begin(&picture); painter.drawLine(0, 0, 100, 100); painter.end(); QImage image(100, 100, QImage::Format_RGB888); image.fill(Qt::white); QPainter imagePainter(&image); imagePainter.drawPicture(0, 0, picture);This example creates a QPicture object, draws a line on it using QPainter, and then uses QPainter to draw the picture onto a QImage. The QPainter class and its drawPicture() function are part of the Qt GUI module, which is included in the Qt package library.