qt异步执行代码
作者:互联网
头文件
#include <QtConcurrent/QtConcurrentRun>
表达式方式
QtConcurrent::run([=]() { // 需要执行的代码 });
执行完触发槽函数
#include <QFutureWatcher> #include <QtConcurrent/QtConcurrentRun> QFutureWatcher<void> *pwatcher = new QFutureWatcher<void>; connect(pwatcher, &QFutureWatcher<void>::finished, this, [=]() { // 执行完后触发该槽函数 }); QFuture<void> future = QtConcurrent::run([=]() { // 需要执行的代码 }); pwatcher->setFuture(future);
转自:https://blog.csdn.net/weixin_45118705/article/details/105760727
标签:异步,执行,run,qt,代码,pwatcher,include,QFutureWatcher,QtConcurrent 来源: https://www.cnblogs.com/qianxiaoPro/p/15729328.html