构建
Qt XML VS Tools 包含 MSBuild 规则和特定于Meta-Object Compiler (moc)、User Interface Compiler (uic) 和Resource Compiler (rcc) 的目标。这些规则被称为Qt/MSBuild。它们允许在并行进程中运行 moc、rcc 和 uic,并设置构建选项,如选择要处理的项目项和处理它们的工具。此外,Qt 工具生成的源文件会在编译过程中添加到 C++ 编译中,因此您无需在项目中包含生成的文件。
你可以在项目级为每个 Qt 工具设置全局选项,也可以为特定文件设置选项。要在项目级设置处理文件的全局选项,请执行以下操作
- 转到Project >Properties >Configuration Properties >Qt Project Settings 。
- 转到项目上下文菜单中的Properties 。

要设置处理特定文件的选项,请转到文件右键菜单中的Properties 。对话框仅列出与文件类型相关的工具。例如,moc 选项可用于 C++ 源文件和头文件,而 uic 选项可用于 UI 表单 (.ui) 。
Qt/MSBuild 项目格式
Qt/MSBuild 项目文件格式在不同的 Qt VS Tools 版本之间有所变化。目前支持版本 3 及更高版本。
如果打开的现有解决方案采用版本 1 的项目格式,则仍可构建。如果是版本 2 格式,只要设置额外的命令行选项,并将默认 Qt 版本设为最初创建项目时的 Qt 版本,就可以构建它。
加载 .pro 文件时,Qt VS Tools 会自动将自定义构建步骤转换为 Qt/MSBuild 步骤。
有关 Qt/MSBuild 项目格式版本的更多信息,请参阅Qt VS Tools - Project format versions。
编译文件的路径
要设置 Qt/MSBuild 文件的路径,请访问Extensions >Qt VS Tools >Options >Qt/MSBuild 。

这相当于设置QTMSBUILDS 环境变量的值。
另请参阅 "构建 Qt/MSBuild 格式 2 的解决方案"、"将解决方案转换为最新的 Qt/MSBuild 格式"和 "加载 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.