const QEvent::Type THREAD_FINISHED_EVENT = static_cast<QEvent::Type>(QEvent::User + 111);class TFinishedEvent : public QEvent{public: TFinishedEvent(const int thread_id) : QEvent ( THREAD_FINISHED_EVENT ), id ( thread_id ) {} void post(QObject *receiver) { QApplication::postEvent( receiver, new TFinishedEvent( id ) ); } int getID() const { return id; }private: int id;};
new TFinishedEvent( id )
void MainWindow::customEvent(QEvent *event){ if ( event -> type() == THREAD_FINISHED_EVENT ) { ui -> teInfo -> append("Message received, ID=" + QString::number( static_cast<TFinishedEvent *>(event) -> ID() ) ); }}