I have the following code which implements QtConcurrent::run()
with QFutureWatcher
to start the fetch()
function which runs a shell process. Upon completion, I want to call the writeDesc
function, but it never gets 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 shows only the debug message Thread done
and not Slot called
. Why isn't writeDesc
being called?