问题记录
运行时出现的问题
运行出现的warning
QWidget::repaint: Recursive repaint detected
在paintEvent中使用painter绘制了线段、图片,移动了QWidget,加入了下面代码导致的
QApplication::processEvents();
屏蔽后没有出现该warning
QApplication::processEvents();
Processes all pending events for the calling thread according to the specified flags until there are no more events to process.
You can call this function occasionally when your program is busy performing a long operation (e.g. copying a file).
In the event that you are running a local loop which calls this function continuously, without an event loop, the DeferredDelete events will not be processed.
This can affect the behaviour of widgets, e.g. QToolTip, that rely on DeferredDelete events to function properly. An alternative would be to call sendPostedEvents() from within that local loop.
Calling this function processes events only for the calling thread.
根据指定的标志处理调用线程的所有挂起事件,直到没有更多的事件要处理为止。
当程序忙于执行长操作(例如,复制文件)时,您可以偶尔调用此函数。
如果您正在运行一个连续调用此函数的本地循环,而没有事件循环,则不会处理DeferredDelete事件。这可能会影响依赖DeferredDelete事件正常工作的小部件(如QToolTip)的行为。另一种选择是从本地循环中调用sendPostedEvents()。
调用此函数只处理调用线程的事件。