Pro is the project file of qmake, and i in pri file is the initial letter of include. It is similar to the header file in C and C + +, that is, we can Part of the pro file is placed in a separate file Pri file, and then included. Using include in the project file of each project is similar to including the header file. In this way, the PRI file can be included in the project, which eliminates the need to set duplicate public variables in each subproject.
For the variable configuration in Qt project file, you can see the variable variable manual in Qt help document, as shown below
The following configuration values control compilation flags:
option | explain |
---|---|
release | The project is built in release mode. If debug is also specified, the last one takes effect. |
debug | The project is built in debug mode. |
debug_and_release | The project is prepared to be built in two modes: debug and release. |
debug_and_release_target | This option is set by default. If debug is also specified_ and_ Release, the final debug and release are built in different directories. |
build_all | If debug is specified_ and_ Release. By default, the project will be built in debug and release modes. |
autogen_precompile_source | Automatically generate a cpp file, contained in The precompiled header file specified in pro. |
ordered | When using subdirs templates, this option specifies that they should be processed in the order of the directory list. |
precompile_header | Support for precompiled header files can be used in projects. |
warn_on | The compiler should output as many warnings as possible. If warn is also specified_ Off, the last one takes effect. |
warn_off | The compiler should output as few warnings as possible. |
exceptions | Enable exception support. Default settings. |
exceptions_off | Disable exception support. |
rtti | Enable RTTI support. By default, the compiler default is used. |
rtti_off | Disable RTTI support. By default, the compiler default is used. |
stl | Enable STL support. By default, the compiler default is used. |
stl_off | Disable STL support. By default, the compiler default is used. |
thread | Enable thread support. Enabled when CONFIG includes qt, which is the default setting. |
c++11 | Enable c++11 support. If the compiler does not support c++11, it has no effect. Support is disabled by default. |
c++14 | Enable c++14 support. If the compiler does not support c++14, it has no effect. By default, support is disabled. |
When the debug and release options are used (the default in Windows), the project will be processed three times: one "meta" Makefile will be generated once, and the other two will be generated Debug and Makefile Release.
In the following times, build_pass and the corresponding debug or release are added to the CONFIG option. This allows it to perform build specific tasks.
For example:
build_pass:CONFIG(debug, debug|release) { unix: TARGET = $$join(TARGET,,,_debug) else: TARGET = $$join(TARGET,,,d) }
DEFINES += USE_MY_STUFF
You can then use it in your code:
#ifdef USE_MY_STUFF // TODO #else // TODO #endif
You can often specify the special version of the project (such as official version and trial version), and restrict some special function modules (such as dongle).
DEPENDPATH += . forms include qrc sources
DESTDIR = ../../lib
FORMS = mydialog.ui \ mywidget.ui \ myconfig.ui
HEADERS = myclass.h \ login.h \ mainwindow.h
INCLUDEPATH = c:/msdev/include d:/stl/include
If the path contains spaces, you need to use quotation marks.
win32:INCLUDEPATH += "C:/mylibs/extra headers" unix:INCLUDEPATH += "/home/user/extra headers"
win32:LIBS += c:/mylibs/math.lib unix:LIBS += -L/usr/local/lib -lmath
If the path contains spaces, you need to include the path in quotation marks.
win32:LIBS += "C:/mylibs/extra libs/extra.lib" unix:LIBS += "-L/home/user/extra libs" -lextra
unix:MOC_DIR = ../myproject/tmp win32:MOC_DIR = c:/myproject/tmp
unix:OBJECTS_DIR = ../myproject/tmp win32:OBJECTS_DIR = c:/myproject/tmp
QT -= gui # Use only core modules
If you want to create an interface that uses XML and network related classes, you need to include the following modules:
QT += core gui widgets xml network
If your project is a Qt Designer plug-in, use the value uiplugin to specify that the project is built into a library, but the specific Qt Designer plug-in supports, please refer to: building and installing the plug in.
unix:RCC_DIR = ../myproject/resources win32:RCC_DIR = c:/myproject/resources
RESOURCES += Resource/resource.qrc
RC_FILE += myapp.rc
RC_ICONS = myapp.ico
SOURCES = myclass.cpp \ login.cpp \ mainwindow.cpp
TEMPLATE = app TARGET = myapp SOURCES = main.cpp
The above project will generate an executable file, which is myapp. Com under Windows Exe, myapp under Unix.
option | explain |
---|---|
app | Create a Makefile for building applications (default). |
lib | Create a Makefile to build the library. |
subdirs | Create a Makefile to build the target subdirectory, which is specified using the subdir variable. |
aux | Create a Makefile that doesn't build anything. If no compiler needs to be called to create a target, such as your project written in an interpreted language, use this function. Note: This template type can only be used for Makefile based generators. In particular, it will not work in vcxproj and Xcode generators. |
vcapp | Windows only. Create a Visual Studio application project. |
vclib | Windows only. Create a Visual Studio library project. |
For example:
TEMPLATE = lib SOURCES = main.cpp TARGET = mylib
TRANSLATIONS += Resource/myapp_zh.ts \ Resource/myapp_en.ts
unix:UI_DIR = ../myproject/ui win32:UI_DIR = c:/myproject/ui
The reference article link of parameter configuration details is as follows: Detailed explanation of pro configuration of Qt , you can pay attention to this blogger. His writing is very good.
If I have time, I will share the more complex use of pri.