当前位置: 首页 > 网络知识

Qt QtConcurrent::run()函数的两种写法

时间:2026-01-29 09:26:22

第一种,使用lambda表达式

1 QFuture<void> future = QtConcurrent::run([=]() ); 4 ...

第二种,使用成员函数

调用QByteArray的成员函数split()

1 // call 'QList<QByteArray> QByteArray::split(char sep) const' in a separate thread 2 QByteArray bytearray = "hello world"; 3 QFuture<QList<QByteArray> > future = QtConcurrent::run(bytearray, &QByteArray::split, ','); 4 ... 5 QList<QByteArray> result = future.result();

调用非成员函数:

1 // call 'void QImage::invertPixels(InvertMode mode)' in a separate thread 2 QImage image = ...; 3 QFuture<void> future = QtConcurrent::run(&image, &QImage::invertPixels, QImage::InvertRgba); 4 ... 5 future.waitForFinished(); 6 // At this point, the pixels in 'image' have been inverted



上一篇:Qt QCustomPlot 使用教程
下一篇:Qt Windows环境下如何添加MYSQL数据库驱动
Qt
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素