Import an existing project
Import existing projects that do not use CMake, qmake, or one of the other directly supported build tools to use Qt Creator as a code editor and to fully control the steps and commands for building the project. To change the way the project is built, change the make
command in the Projects mode under Build Settings.
With the following files, you can specify which files belong to your project and which include directories or defines to pass to your compiler: .files
, .includes
, and .config
.
To import an existing generic project:
- Select File > New Project > Import Project > Import Existing Project.
- 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 and shows them in the Projects view:
.files
.includes
.config
.creator
.cflags
.cxxflags
The .creator
file is considered the project file, so you need to open it when you want to open the project later.
Specify files
For a generic project, you have to manually specify which files belong to your project in the .files
file. When you import 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 updates the contents of Projects when you save the .files
file. Or, use the context menu in Projects to add and remove files or directories.
Use a script
If you frequently need to update the .files
file, use a script. If the file is modified externally, you have to close and reopen the project for the changes to take effect.
To update the .files
file in the Git repository, use the following script:
git ls-files "*.cpp" "*.h" > MyProject.files
Precompiled headers
To use precompiled headers in a generic project, add the pch
tag after a file path in the .files
file, separated by the pipe character (|). For example:
src/pch.h|pch
Specify include paths and framework paths
Specify include paths in the .includes
file, one include path per line. The paths can be either absolute or relative to the .includes
file.
Lines starting with -F
are interpreted as framework paths.
Specify defines
Specify defines in the .config
file. It 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
Forward flags to Clang code model
The .cxxflags
and .cflags
files have command-line flags for the Clang code model on a single line.
For example, add the -std=c++11
line to set the language version for parsing as C++11.
Provide deployment information
To run an application on a remote Linux device, you first need to deploy your executable and possibly other files. Qt Creator does that for you automatically if you enter the necessary information. This works the same way as explained for CMake in Remote Linux Deploy Configuration, except that you also need to include your application binary in the list.
Create a run configuration
Qt Creator cannot automatically determine which executable to run, so you must set the executable in Projects > Run > Add > Custom Executable.
See also Specify a custom executable to run, Use project wizards, and Configuring Projects.
© 2024 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.