So, you call that from a worker thread, right?
Well, in Qt4 this does not work anymore. No widget can be modified by any thread other than the GUI thread.
Solution:
Add a signal to the worker thread, with 2 parameter.
Add a slot in the GUI class that owns/has access to the status bar.
When you want to change the status message, just emit that signal:
emit updateStatus(strError,15000);
emit updateStatus(strError,15000);
To copy to clipboard, switch view to plain text mode
The slot in the GUI:
void GUIClass
::updateSlot(QString msg,
int code
) {
statusWidget->message(msg,code);
}
void GUIClass::updateSlot(QString msg, int code )
{
statusWidget->message(msg,code);
}
To copy to clipboard, switch view to plain text mode
Something like this.
When emitting signals across threads, they are actually posted as events in the destination threads.
So your signal will become an event that will cause the slot in the GUI thread to execute asynchronously.
The point is to let the GUI thread handle modifications in the widgets.
The slot will execute in the GUI thread's context.
Regards
Bookmarks