Total Articles 180
In working thread, you need to switch into a main thread. In this case, you can use QEvent class.
[myobj.h]
class MyObj : public QObject { Q_OBJECT public: bool event(QEvent* event); };
[myobj.cpp]
bool MyObj::event(QEvent* event){qDebug() << QThread::currentThreadId() << "MyObj::event";return QObject::event(event);}
[main.cpp]
class MyThread : public QThread { ... protected: void run() { ... QCoreApplication::postEvent(myObj, new QEvent(QEvent::User)); ... } };
[Download]