如何只对QWidget的局部区域的显示内容更新

来源:互联网 发布:中华网络一条龙可靠么 编辑:程序博客网 时间:2024/06/05 19:17
比方说我想在原先有背景图片的widget中更新某个局部区域的图片时采用这种方法
void Widget::paniterEvent(QPainterEvent *)
{
     QPainter painter(this);
     painter.drawPixmap(30,30,100,100,newpicture);
}

结果会把整个Widget里的内容擦除,然后在指定区域画上新图片。
请问一个用什么方法可以只对局部区域的显示内容更新,而不影响全局。

遇问题还是得多查帮助文档啊,
void QWidget::repaint ( int x, int y, int w, int h )
This is an overloaded function.

This version repaints a rectangle (x, y, w, h) inside the widget.

If w is negative, it is replaced with width() - x, and if h is negative, it is replaced width height() - y.

void QWidget::repaint ( const QRect & rect )
This is an overloaded function.

This version repaints a rectangle rect inside the widget.

void QWidget::repaint ( const QRegion & rgn )
This is an overloaded function.

This version repaints a region rgn inside the widget..
原创粉丝点击