qt 如果你要繪製窗口,就可以直接實現該函數。 QPaintEvent 會包含要刷新的區域。
void WindowVideoSingle::paintEvent( QPaintEvent* pe )
{
QRect rc = this->rect();
QPainter p( this );
QPen pen( QColor::fromRgb(0,255,0));
p.setPen( pen );
rc.setLeft( rc.left() + 1 );
rc.setTop( rc.top() + 1 );
rc.setRight( rc.right() - 1 );
rc.setBottom( rc.bottom() - 1 );
p.drawRect( rc );
}
當你有子窗口的時候, 子窗口的刷新事件也會發送到這裏。 pe->rect()是需要刷新的區域 。