how to force widgets update
Hi, the following code
Code:
statusLabel
= new QLabel(" idle ",
this);
statusBar()->addWidget(statusLabel);
statusLabel->setText("doing something");
myobject->do_smth_for_minute();
statusLabel->setText("something done");
does not update the statusLabel, it just stays "something done". How can I force updating the widget?
Re: how to force widgets update
Re: how to force widgets update
You are blocking the event loop so the widget can't update itself. Read this article: [wiki]Keeping the GUI Responsive[/wiki].
Re: how to force widgets update
update() does not work (on windows at least). That is the point, I am afraid I need to put a task to a thread, but that just is not right, I do not need it to be responsive in between two updates of the widget, I only want to update it once before and once afterwards.
Re: how to force widgets update
an easy way, set a QTimer which will timeout in a few millisec,connect its timeout SIGNAL
Re: how to force widgets update
See the part of the article that deals with manually triggering event processing.
@MorrisLiang: I'm afraid this won't work as event loop is blocked so timers don't fire. update() is called, it just doesn't cause the desired effect.