repaint会立刻调用paintEvent重绘,而update是把绘制事件加入主事件循环。
Qt文档:
[slot] void QWidget::repaint()
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden.
We suggest only using repaint() if you need an immediate repaint, for example during animation. In almost all circumstances update() is better, as it permits Qt to optimize for speed and minimize flicker.
Warning: If you call repaint() in a function which may itself be called from paintEvent(), you may get infinite recursion. The update() function never causes recursion.
会立刻调用paintEvent()函数来进行重绘,除非这时候不可以update或控件是