AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
[TOC] ## QtConcurrent 使用时,需要在 .pro 文件中添加 模块 ``` QT += core gui concurrent ``` ## 示例 ### Run 方法 ``` void Hello(QString msg){ qDebug()<<msg; QThread::sleep(2); qDebug()<<QThread::currentThreadId(); } QFuture<void> f1 = QtConcurrent::run(Hello,QString("hell")); QFuture<void> f2 = QtConcurrent::run(Hello,QString("word")); f1.waitForFinished(); f2.waitForFinished(); ``` ### 类方法 ``` QtConcurrent::run(QThreadPool::globalInstance(),this, &QtWidgetsApplication1::hello); void QtWidgetsApplication1::hello() { for (int i = 0; i < 3; ++i) { qDebug() << "hello world"; QThread::sleep(1); } } ```