void QWidget::update ()分析重绘事件激活

void QWidget::update ()分析重绘事件激活 1看看手册中这段话
void QWidget::update () [slot]
Updates the widget unless updates are disabled or the widget is hidden.
This function does not cause an immediate repaint; instead it schedules a paint event for processing when Qt returns to the main event loop. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.
Calling update() several times normally results in just one paintEvent() call.
Qt normally erases the widget's area before the paintEvent() call. If the WRepaintNoErase widget flag is set, the widget is responsible for painting all its pixels itself.
See also repaint(), paintEvent(), updatesEnabled, erase(), and setWFlags().
2.update() 激发Paint Event 事件的发生,而Paint Event 时间将调用QWidegt::PaintEvent(QPaintEvent paint)
而这个Protected函数是定义窗口自己的绘制特性。
3.void QWidget::update () [槽]
更新窗口部件,除非更新已经失效或者窗口部件被隐藏。
这个函数不会导致一个立刻的重新绘制——更正确的是,当Qt回到主事件回路中时,它规划了所要处理的绘制事件。这样允许Qt来优化得到比调用repaint()更快的速度和更少的闪烁。
几次调用update()的结果通常仅仅是一次paintEvent()调用。
Qt通常在paintEvent()调用之前擦除这个窗口部件的区域。仅仅只有在WRepaintNoErase窗口部件标记被设置的时候,窗口部件本身对绘制它所有的像素负有责任。

原文地址:https://www.cnblogs.com/hnrainll/p/2057766.html