在此页面上

Qt 任务树

Qt TaskTree 提供了一种声明式方法,可通过适当的错误处理和执行策略来组成和执行异步任务工作流。

注意: 6.11 中的 Qt TaskTree 处于技术预览版中,其 API 不在Qt 的兼容性承诺范围内。

开始使用

Qt TaskTree 允许您创建具有不同执行策略、并行/顺序执行和适当错误处理的复杂任务分层。

关键概念

  • Recipes- 任务工作流程的声明性描述。
  • - 为子任务定义执行策略的容器。
  • 存储- 线程本地存储系统,用于在任务间共享数据。
  • 迭代器- 支持循环和重复任务执行。

使用模块

使用 Qt 模块的 C++ API 需要直接或通过其他依赖关系链接模块库。一些构建工具对此提供了专门支持,包括CMakeqmake

使用 CMake 构建

使用find_package() 命令在Qt6 软件包中找到所需的模块组件:

find_package(Qt6 REQUIRED COMPONENTS TaskTree)
target_link_libraries(mytarget PRIVATE Qt6::TaskTree)

更多详情,请参阅使用 CMake 构建概述。

使用 qmake 构建

要配置模块以便用 qmake 构建,请在项目的 .pro 文件中添加模块作为QT 变量的值:

QT += tasktree

任务适配器

模块包含多个内置任务适配器,用于执行常见操作:

工作流策略

组支持不同的工作流策略来处理任务结果:

示例

参考

许可证

Qt TaskTree 模块可从The Qt Company 获得商业许可。此外,它还受自由软件许可证的保护:GNU 宽通用公共许可证第 3 版GNU 通用公共许可证第 2 版。更多详情,请参阅Qt 许可

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.