我有一个 QMainWindow
实例,它需要连续读取 xml 文件。第一个文件包含构建 ui 所需的所有信息,第二个文件包含所有元数据。所以在我的 MainWindow
的 open
函数中,我想在读取第一个文件后绘制 ui,例如:
在 MainWindow
的 open
范围内:
readFirstFile(QString filename);
update();
readSecondFile(QString filename);
但是以上没有效果。如何在读取第二个文件之前强制绘画?
最佳答案
如果您需要立即重绘,您可以使用 repaint()
而不是 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. This permits Qt to optimize for more speed and less flicker than a call to repaint() does.
关于c++ - 如何在Qt中强制绘画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42246526/