qt 之 paintEvent(QPaintEvent *pe)

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()是需要刷新的區域 。

發佈了136 篇原創文章 · 獲贊 5 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章