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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章