[英]How to enforce painting in Qt?
I have a QMainWindow
instance, which consecuctively needs to read to xml files. 我有一个
QMainWindow
实例,因此需要读取XML文件。 The first file holds all necessary information to construct the ui and the second all meta-data. 第一个文件包含构造ui的所有必要信息,第二个文件包含所有元数据。 So in my
MainWindow
's open
function i would like to paint the ui after reading the first file like: 因此,在
MainWindow
的open
函数中,我想在读取第一个文件后绘制ui:
in MainWindow
's open
scope: 在
MainWindow
的open
范围中:
readFirstFile(QString filename);
update();
readSecondFile(QString filename);
But the above has no effect. 但是以上没有效果。 How can i enforce painting before reading the second file?
在读取第二个文件之前,如何执行绘画?
If you need an immediate repaint you can use repaint()
instead of update()
. 如果需要立即重绘,则可以使用
repaint()
而不是update()
。
from the Qt doc of QWidget::update()
来自
QWidget::update()
的Qt文档
This function does not cause an immediate repaint;
此功能不会导致立即重绘; instead it schedules a paint event for processing when Qt returns to the main event loop.
相反,当Qt返回到主事件循环时,它将安排一个绘画事件进行处理。 This permits Qt to optimize for more speed and less flicker than a call to repaint() does.
与对repaint()的调用相比,这允许Qt优化以提高速度和减少闪烁。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.