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 );
}
//...
//...
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 );
}