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/archive/2011/05/26/2057766.html

 

總之:update會調用PaintEvent,往往PaintEvent是子類重新定義的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM