Add subprojects to projects

You can link your application to Qt libraries and other libraries, such as system libraries or your own libraries. Further, your own libraries might link to other libraries. To compile your project and benefit from services such as code completion and syntax highlighting, add the libraries to your project.

Create subprojects

To create subprojects and add them to a project:

  1. Right-click the project name in the Projects view to open the context menu, and select New Subproject.
  2. Follow the instructions of the wizard to create a subproject.

    {New Project dialog}

Add existing projects as subprojects

To add an existing project as a subproject:

  1. Select Add Existing Projects in the context menu.
  2. In the file browser dialog, locate your subproject.

Create SUBDIRS projects for qmake

When you create a new project and select qmake as the build system, you can add it to another project as a subproject in the Project Management dialog. However, the root project must specify that qmake uses the subdirs template to build the project.

To create a root project:

  1. Select File > New Project > Other Project > Subdirs Project > Choose.
  2. On the Summary page, select Finish & Add Subproject to create the root project and to add another project, such as a C++ library.

The wizard creates a project file (.pro) that defines a subdirs template and the subproject that you add as a value of the SUBDIRS variable. It also adds all the necessary files for the subproject.

Specify dependencies

To specify dependencies, use the Add Library wizard.

Remove subprojects

To remove subprojects, right-click the project name in the Projects view, and select Remove Subproject in the context menu.

See also Creating Projects, Use project wizards, Add libraries to qmake projects, and Add libraries to CMake projects.

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.