
Originally Posted by
bmesing
However it seems quiet a limitation not being able to access widgets directly.
If all widget access was to be thread-safe, you'd have to protect every call that changes internal structures of the widget with a mutex, which would cause a great performance hit.
It also seems like one has to know many internals, to distinguish which method call raises an event.
No, you don't. As you see Qt cares about it for you. And the general rule is not to do any calls to objects living in another thread without being sure they are thread safe (there is a list of thread safe calls in the docs somewhere).
Probably its best to avoid calls of any QWidget methods from another Thread.
Exactly. Most of the calls can be done using signals and slots which are thread-safe in Qt4 and that's how most actions should be handled.In your case it should roughly look like:
_pEventNotifyDlg->_pMessageDisplay->setPlainText("Test2");
connect(this,
SIGNAL(someSignal
(const QString &)),
_pEventNotifyDlg->_pMessageDisplay,
SLOT(setPlainText
(const QString &)) );
//...
emit someSignal("some text");
_pEventNotifyDlg->_pMessageDisplay->setPlainText("Test2");
connect(this,
SIGNAL(someSignal(const QString &)),
_pEventNotifyDlg->_pMessageDisplay,
SLOT(setPlainText(const QString &))
);
//...
emit someSignal("some text");
To copy to clipboard, switch view to plain text mode
Bookmarks