Qt:更新qwidget的一个区域 [英] Qt: Update an area of qwidget

查看:332
本文介绍了Qt:更新qwidget的一个区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,需要一些帮助。

我有一个具有绘画事件的Qwidget,假设我的qwidget上有3个区域是区域1,区域2和区域3.我想重新绘制区域2和区域3(不重绘区域1) )当我调用Qwidget的更新或重绘时。我怎么能这样做。

I have a problem, need some helps.
I have a Qwidget that have paint event, assume I have 3 areas on my qwidget are area 1, area 2 and area 3. I want to repaint only area 2 and area 3(not repaint area 1) when I call update or repaint of Qwidget. How can I do that.

推荐答案

你可以使用一个重载的 QWidget update() [ ^ ]接受坐标,矩形或通过覆盖区域2和区域3而不是区域1的区域的区域的函数。



paintEvent()处理程序中传递由 QPaintEvent <提供的区域/ code>使用其中一个 QPainter 实例处理程序。 html#clipping>剪辑 [ ^ ]功能。然后即使在为它们调用绘图功能时也不会绘制区域外的部分。或者,检查通过的区域并仅绘制被覆盖的部分。
You can use one of the overloaded QWidget update()[^] functions that accept coordinates, a rect, or a region passing an area covering your area2 and area3 but not area1.

In your paintEvent() handler pass the area which is provided by QPaintEvent to the used QPainter instance handler using one of it's clipping[^] functions. Then the parts outside the area will not be drawn even when calling drawing function for them. Alternatively check the passed area and draw only those parts that are covered.


这篇关于Qt:更新qwidget的一个区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆