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
,和
.config
.
To import an existing generic project:
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
文件。
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.
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 or directories 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
在
Git
repository use the following script:
git ls-files "*.cpp" "*.h" > MyProject.files
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
文件。
Lines starting with "-F" are interpreted as framework paths.
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
The
.cxxflags
and
.cflags
files contain command line flags for the Clang code model on a single line.
For example, specify the
-std=c++11
to set the language version for parsing as C++11.
If you want to run your application on a generic remote Linux device, you first need to deploy your executable and possibly other files. Qt Creator does that for you automatically if you provide the necessary information. This works the same way as explained for CMake here , except that you also need to include your application binary in the list.
Qt Creator cannot automatically determine which executable to run.
在 Projects mode under Run Settings , define the executable file to run: