class ProgressEvent : public QEvent{public: enum { TypeId = QEvent::User + 1001 }; ProgressEvent( const QString& operation, int progress ) : QEvent( ProgressEvent::TypeId ), opname(QDeepCopy<QString> (operation) ), prgs(progress) {} QString operation() const { return opname; } int progress() const { return prgs; }private: QString opname; int prgs; };
QString opname = "Initializing";int prgs = 50;QApplication::postEvent( receiver, new ProgressEvent( opname, prgs ) );
bool Receiver::event( QEvent* e ){ if ( e->type() == ProgressEvent::TypeId ) { ProgressEvent* pe = (ProgressEvent*) e; progressDialog->setLabelText( pe->operation() ); progressDialog->setProgress( pe->progress() ); return true; } return false;}