PDA

View Full Version : How to emit progressTextChanged (QString) signal in QFutureWatcher?



andrex289
18th April 2012, 19:06
Having this code is possible to emit the progressTextChanged(QString) signal? i have tried but i when trying to access the signal the compiler says it is protected.


//...
//...
QFuture<bool> future = QtConcurrent::run(
this,
&MyClass::runTheTask );

QFutureWatcher<bool> watcher;
connect( &watcher, SIGNAL( progressTextChanged( const QString ) ),
this, SLOT( appendMessageToStatusLineEdit( const QString ) ) );
watcher.setFuture( future );
future.waitForFinished();

// ...
// ...




bool MyClass::runTheTask()
{
// do the task



// how to emit progress text signal???
}

void MyClass::appendMessageToStatusLineEdit( const QString msg )
{
QMetaObject::invokeMethod( this,
"doAppendMessageToStatusLineEdit",
Qt::QueuedConnection,
Q_ARG( QString, msg ) );
}

void MyClass::doAppendMessageToStatusLineEdit( const QString msg )
{
_ui->statusTextEdit->append( msg );
}

amleto
18th April 2012, 19:14
you cant emit a signal that does not belong to your class.

QFutureWatcher decides when to emit that signal - you do not!