I have the following code that implements QtConcurrent::run()using QFutureWatcherto run a function fetch()that starts a shell process. Upon completion, I want to call the function writeDesc, but it is never called.
void MyClass::on_fetchButton_clicked()
{
QFuture<void> fetcher;
QFutureWatcher<void> watcher;
connect(&watcher, SIGNAL(finished()), this, SLOT(writeDesc()));
fetcher = QtConcurrent::run(this, &MyClass::fetch);
watcher.setFuture(fetcher);
}
void MyClass::fetch()
{
[...]
qDebug()<<"Thread done";
}
void MyClass::writeDesc()
{
qDebug()<<"Slot called";
[...]
}
fetch()works fine, but the program only shows a debug message Thread done, not Slot called. Why not called writeDesc?
source
share