Skip to content

Instantly share code, notes, and snippets.

@estan
Created March 24, 2018 09:20
Show Gist options
  • Save estan/17f56e70a33b4212562afcae506e2fd8 to your computer and use it in GitHub Desktop.
Save estan/17f56e70a33b4212562afcae506e2fd8 to your computer and use it in GitHub Desktop.
auto future = QtConcurrent::run(doHeavyStuff);
auto watcher = new QFutureWatcher<ResultType>(this);
connect(watcher, &QFutureWatcher<ResultType>::finished, [future]() {
// Do stuff here, you have the return value of doHeavyStuff in future.result()...
});
connect(watcher, &QFutureWatcher<ResultType>::finished,
watcher, &QFutureWatcher<ResultType>::deleteLater);
watcher->setFuture(future);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment