Hello,
I have the following code that is located in the run() method of my class which is derived from QThread:
_pEventNotifyDlg->_pDateDisplay->setText("Test1");
_pEventNotifyDlg->_pMessageDisplay->setPlainText("Test2");
_pEventNotifyDlg->_pDateDisplay->setText("Test1");
_pEventNotifyDlg->_pMessageDisplay->setPlainText("Test2");
To copy to clipboard, switch view to plain text mode
While the first call works fine, the second causes a crash with the following error message:
QObject::startTimer: timers cannot be started from another thread
QObject::connect: Cannot queue arguments of type
'QRectF' ASSERT failure in
QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 81d1800. Receiver '' (of type 'QTextDocument') was created in thread 8061188", file kernel/qcoreapplication.cpp, line 293
Aborted
QObject::startTimer: timers cannot be started from another thread
QObject::connect: Cannot queue arguments of type 'QRectF'
ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 81d1800.
Receiver '' (of type 'QTextDocument') was created in thread 8061188", file kernel/qcoreapplication.cpp, line 293
Aborted
To copy to clipboard, switch view to plain text mode
The _pEventNotifyDlg is an instance of a dialog class which belongs to the main thread. _pDateDisplay is a QLabel, and _pMessageDisplay is a QTextBrowser. I do not see that I am sending any events there, but I guess it is triggered by the setPlainText() method call.
Can anybody explain that behaviour to me? Am I misunderstanding something fundamental about threads?
Thanks Ben
QT Version 4.1.3
Bookmarks