为项目添加子项目
您可以将应用程序链接到 Qt 库和其他库,如系统库或您自己的库。此外,您自己的库也可能链接到其他库。要编译项目并享受代码补全和语法高亮等服务,请将库添加到项目中。
创建子项目
创建子项目并将其添加到项目中:
- 右键单击 "项目"视图中的项目名称打开上下文菜单,然后选择New Subproject 。
- 按照向导的指示创建子项目。
将现有项目添加为子项目
将现有项目添加为子项目:
- 在上下文菜单中选择Add Existing Projects 。
- 在文件浏览器对话框中找到子项目。
为 qmake 创建 SUBDIRS 项目
当你创建一个新项目并选择 qmake 作为构建系统时,你可以在Project Management 对话框中将其作为子项目添加到另一个项目中。不过,根项目必须指定 qmake 使用subdirs
模板来构建项目。
创建根项目
- 选择File >New Project >Other Project >Subdirs Project >Choose 。
- 在Summary 页面,选择Finish & Add Subproject 创建根项目并添加另一个项目,如 C++ 库。
向导会创建一个项目文件(.pro),其中定义了subdirs
模板和作为SUBDIRS 变量值添加的子项目。向导还会添加子项目所需的所有文件。
指定依赖关系
要指定依赖关系,请使用Add Library 向导。
删除子项目
要删除子项目,请右键单击Projects 视图中的项目名称,然后在上下文菜单中选择Remove Subproject 。
另请参阅 "创建项目"、"使用项目 向导"、"为 qmake 项目添加库"和 "为 CMake 项目添加库"。
Copyright © The Qt Company Ltd. and other contributors. 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.