Double buffering
void Plotter::refreshPixmap() { pixmap = QPixmap(size()); pixmap.fill(this, 0, 0); QPainter painter(&pixmap); painter.initFrom(this); drawGrid(&painter); drawCurves(&painter); update(); }
QPixmap stored in the graphics memory, it is optimized for a particular screen, and therefore, it is the device (graphics engine's operating system) is closely related to the actual underlying display.
When the picture is small, the load directly with QPixmap; big picture when the time is preferably loaded through the QImage, then drawn again QPixmap user. E.g:
QImage image; image.load(":/pics/earth.png" ); QPainter painter(this); QPixmap pixmapToShow = QPixmap::fromImage( image.scaled(size(), Qt::KeepAspectRatio) ); painter.drawPixmap(0,0, pixmapToShow); // attachment QPixmap and method of mutual conversion QImage QImage QPixmap :: The toImage () const ; static QPixmap QPixmap :: fromImage ( const QImage & Image ,,,); // QPicture not convert from these two types, only from IO device path or file name to load. BOOL Load (a QIODevice dev *, const char * = the format Q_NULLPTR); BOOL Load ( const QString & fileName, const char * = Q_NULLPTR the format);
The reference csdn's blog: https://blog.csdn.net/qq_33266987/article/details/73187140