简体   繁体   中英

How to enforce painting in Qt?

I have a QMainWindow instance, which consecuctively needs to read to xml files. The first file holds all necessary information to construct the ui and the second all meta-data. So in my MainWindow 's open function i would like to paint the ui after reading the first file like:

in MainWindow 's open scope:

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() .

from the Qt doc of QWidget::update()

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM