Example:
void CuteWidget::paintEvent( QPaintEvent *e )
{
QRect ur = e->rect(); // rectangle to update
QPixmap pix( ur.size() ); // Pixmap for double-buffering
pix.fill( this, ur.topLeft() ); // fill with widget background
QPainter p( &pix );
p.translate( -ur.x(), -ur.y() ); // use widget coordinate system
// when drawing on pixmap
// ... draw on pixmap ...
p.end();
bitBlt( this, ur.topLeft(), &pix );
}
这是双缓冲的,QT手册中QPixmap Class例子