Skip to content

Instantly share code, notes, and snippets.

@estan
Created March 24, 2018 09:21
Show Gist options
  • Save estan/80184b53b7b7120eefb9f0f6b608d000 to your computer and use it in GitHub Desktop.
Save estan/80184b53b7b7120eefb9f0f6b608d000 to your computer and use it in GitHub Desktop.
int someParam = 1;
auto future = QtConcurrent::run(doHeavyStuff);
auto watcher = new QFutureWatcher<ResultType>(this);
connect(watcher, &QFutureWatcher<ResultType>::finished, [future, someParam]() {
// 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