PDA

View Full Version : how to force an immediate repaint on a widget



mortoray
12th October 2010, 13:45
On startup I do some synchronous processing and would like to update a QLabel object. The trouble is that since I don't go back to the event loop it won't redraw.

I've tried calling "repaint" but it still doesn't force an immediate redraw (like the docs say it does).

I've found that QCoreApplication::processEvents does the trick, but I'd prefer if I could somehow just redraw the one label widget.

Timoteo
12th October 2010, 14:08
Have a look at this:

http://www.qtcentre.org/wiki/index.php?title=Keeping_the_GUI_Responsive

mortoray
12th October 2010, 14:13
Thank you. I do a lot of that already once the program starts. I'm just stuck in the very specific case where I wish to do nothing but have one widget in particular redraw. This happens only during startup -- once started the app is totally asynchronous with all processing.

squidge
12th October 2010, 17:31
All GUI operations are done using an event loop, which means that your GUI thread should be responsive at ALL times, including startup. Commands such as repaint simply queue these requests in the message loop.

If you have startup code that takes a long time to finish you should place this into a seperate thread, else you could find you are in an situation where the OS sends you a message, you do not reply and then the OS will freeze your window and display a message stating "This application is no longer responding.".