Setting Up a Generic Project

Generic project support allows you to use Qt Creator as a code editor. You can change the way your project is built by modifying the make command in the Projects mode under Build Settings.

When you import a project, Qt Creator creates the following files that allow you to specify which files belong to your project and which include directories or defines you want to pass to your compiler: .files, .includes, and .config.

Importing a Generic Project

To import an existing generic project:

  1. Select File > New File or Project > Import Project > Import Existing Project.
  2. In Import Existing Project, enter the project name and select the location of the project file you want to import.

    Qt Creator automatically generates the following files in the project directory:

When the project is successfully imported, Qt Creator creates the project tree in the sidebar.

After importing a generic project into Qt Creator, open it by selecting the .creator file.

Working with Generic Project Files

For a generic project, you have to manually specify which files belong to your project and which include directories or defines you want to pass to your compiler.

Specifying Files

The list of files for a generic project is specified in the .files file. When you first create a generic project, Qt Creator adds any files it recognizes to your project.

To add or remove files, edit the .files file in Qt Creator. Qt Creator recreates your project tree when you save the .files file. Alternatively, you can add and remove files using the context menu in the project tree.

If you frequently need to update the .files file, you can do so efficiently by using a script that updates the file for you. If the file is modified externally, you have to restart Qt Creator for the changes to take effect.

To update the .files on the Git repository use the following script:

git ls-files "*.cpp" "*.h" > MyProject.files

Specifying Include Paths

The include paths are specified in the .includes file, one include path per line. The paths can be either absolute or relative to the .includes file.

Specifying Defines

The defines are specified in the .config file. The .config file is a regular C++ file, prepended to all your source files when they are parsed. Only use the .config file to add lines as in the example below:

#define NAME value

Creating a Run Configuration

Qt Creator cannot automatically determine which executable to run.

In the Projects mode under Run Settings, define the executable file to run:

  1. Click Add and select Custom Executable.
  2. Define the configuration name, the location of the executable, any additional arguments and the working directory.

© 2017 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.