- QFuture:表示异步计算的结果
- QFutureWatcher:QFuture本身不带信号槽,可使用QFutureWatcher进行监控QFutureWatcher 接收该事件后发送对应信号。
//concurrent生成future
QFuture<void> future = QtConcurrent::run([this]{ /**/ });
//future设置给watcher进行监控
QFutureWatcher<void> theWatcher;
theWatcher.setFuture(future);
//future对应的操作结束,触发watcher信号
connect(&theWatcher,&QFutureWatcher<void>::finished,this,[this]{ /**/ });
QFuture
用于表示异步操作的结果,可以通过QFutureWatcher
来监控和获取结果。QConcurrent
提供了一些函数和工具来简化并发编程,比如QtConcurrent::run
和QtConcurrent::map
。