I have following code which works (but it should not work)
void myfunction(){
auto future = function_which_return_future();
auto *watcher = new QFutureWatcher<VariantTable>;
QObject::connect(watcher,&QFutureWatcher<VariantTable>::finished,this,[=](){
VariantTable table = future.result();
// do some stuff
delete watcher;
});
watcher->setFuture(future);
}
In this code, future goes out of scope but code inside watched's slot still get executed.
Is this because things are happening too fast and will my code may fail if things slowdown ? or its just that I don't need future after calling QFutureWatcher::setFuture ?