In QT, a tool named qmake can generate a makefile, which is generated by the. Pro file. The. Pro file is written as follows:
1. Notes
Starting from "#" to the end of this line.
2. The template variable tells qmake which makefile is generated for this application. The following are available options:
Template = app
A> app-create a makefile for the application. This is the default value, so if the template is not specified, this will be used.
B> Lib-create a makefile for the library.
C> vcapp-create a visual Studio project file for the application.
D> vclib-create a library's Visual Studio project file.
E> subdirs-this is a special template. It can create a makefile that can enter a specific directory, generate makefile for a project file, and call make for it.
# Specify the directory where the generated application is stored
Destdir + = ../bin
# Specify the name of the generated Application
Target = pksystem
# Configuration information
Config is used to tell qmake about the application configuration.
Config + = QT warn_on release
"+ =" Is used here because we add our configuration options to any existing one. It is safer to replace all specified options as "=.
A> the QT section tells qmake that the application uses QT to connect to the program. This means that qmake considers the QT library when connecting and adding the required include path for compilation.
B> the warn_on section tells qmake to set the compiler to output warning information.
C> the release section tells qmake that the application must be connected to a published application. In the development process, programmers can also use DEBUG to replace release.
# Specify the UIC command to convert the. UI file to the directory where the UI _ *. h file is stored
Ui_dir + = forms
# Specify the RCC command to convert the. qrc file to the directory where qrc _ *. H files are stored
Rcc_dir + = ../tmp
# Specify the MOC command to convert the header file containing q_object to the storage directory of the standard. h file
Moc_dir + = ../tmp
# Specify the directory where the object (OBJ) is stored
Objects_dir + = ../tmp
# Related paths for program Compilation
Dependpath + =. forms include qrc sources
# Header file inclusion path
Includepath + =.
# Information generated during qmake, [$ {A} reads the string of variable A], and [$ (PATH) reads the path of the environment variable]
# Message ($ (PATH ))
# Source file encoding
Codecforsrc = GBK
# Header files contained in the project
Headers + = include/painter. h
#. Uidesign file contained in the project
Forms + = forms/painter. UI
# Source files contained in the project
Sources + = sources/Main. cpp sources/painter. cpp
# Resource files contained in the project
Resources + = qrc/painter. qrc
Libs + =-l folderpath // path of the introduced lib file-L: Import path
Release: libs + =-l folderpath // The LIB file path introduced by release
Debug: libs + =-l folderpath // lib file path introduced by debug
Defines + = xx_xx_xxx // define the compilation option. In the. h file, you can use: # ifdefine xx_xx_xxx.
Rc_file = xxx. icns
7. Platform relevance Processing
What we need to do here is to use the corresponding scope for Processing Based on the platform that qmake runs. The simple scope of the platform-dependent files added for the Windows platform looks like this:
Win32 {
Sources + = hello_win.cpp
}
========================================================== ========================================================== ==========================================
When you have created your project file, it is easy to generate the makefile. All you have to do is first go to the project file you generated and enter:
Makefile can be generated by the. Pro file as follows:
Qmake-omakefile hello. Pro
For Visual Studio users, qmake can also generate the ". DSP" file, for example:
Qmake-tvcapp-O hello. DSP hello. Pro
++ A pro file instance ++ ++
Template = app # module configuration
Language = C ++ # C ++ Language
Config + = QT warn_on debug release
# Introduced lib file used to introduce dynamic link library
Libs + = qaxcontainer. Lib
# Header file inclusion path
Export depath + = .. /.. /qtcompnent/qtchklisten/Inc .. /.. /qtcompnent/qtclearfile/Inc .. /.. /validator/INC/validerrcode .. /.. /qtcompnent/qtdir/INC .. /INC .. /.. /utillib/INC/xmlapi .. /.. /utillib/INC/util .. /.. /xercesc .. /.. /qtcompnent/qteditor/Inc .. /.. /qtcompnent/qtfunreview/Inc .. /.. /qtcompnent/qttable/Inc .. /.. /qtcompnent/qtversion/Inc .. /.. /qtcompnent/qini/Inc .. /.. /icdtool/icdservices/Inc .. /.. /icdtool/dataset/INC .. /.. /icdtool/Doi/INC .. /.. /icdtool/reportcontrol/INC .. /.. /icdtool/gseconctrol/INC .. /.. /icdtool/inputs/Inc .. /.. /icdtool/smvconctrol/INC .. /.. /icdtool/logcontrol/INC .. /.. /Content preview/INC/Content preview toollib .. /.. /bqpreview/form .. /.. /icdtool/sclcontrol/Inc .. /.. /icdtool/log/INC .. /.. /icdtool/settingcontrol/INC .. /.. /qtcompnent/qteditor/Inc .. /.. /qtcompnent/qttreeview/Inc .. /.. /qtcompnent/qttabwidget/INC .. /.. /communication/INC .. /.. /qtcompnent/qtabout/Inc .. /iedmanage/INC .. /ldmanage/INC .. /foriecrun/INC .. /.. /qtcompnent/validset/INC
# Header files contained in the project
Headers + = ../INC/exportstable. h/
../INC/maintabwidget. h/
../INC/outputtab. h/
../INC/strutil. h/
../INC/treeeditview. h/
../INC/mainform. h/
../INC/recenfileini. h/
../INC/exportcidfunction. h
# Source files contained in the project
Sources + = ../src/Main. CPP/
../Src/exportstable. CPP/
../Src/maintabwidget. CPP/
../Src/outputtab. CPP/
../Src/treeeditview. CPP/
../Src/mainform. CPP/
../Src/recenfileini. CPP/
../Src/exportcidfunction. cpp
#. Uidesign file contained in the project
Forms = ../form/sp_mainform. UI/
../Form/exportiedform. UI/
../Form/exportsedform. UI/
../Form/importsedform. UI/
../Form/formiminputs. UI
# Image files
Images = images/substation.png/
Images/communication.png/
Images/autocom.png/
Images/reportcfg.png/
Images/comcfg.png/
Images/filetrans.png/
Images/review.png/
Images/setting.png
# Resource files contained in the project
Resources = scintilla. qrc
# Config-= release
Config-= debug
Rc_file = maid. RC
Binlib = ../bin ../xercesc/lib
The transfer of the ui_headers_dir = ../INC #. UI file to the directory stored in **. h
Ui_sources_dir = ../src #. Transfer the UI file to the directory stored in **. cpp
Qmake_libdir =$ {binlib}
Release {
Target = stctool # specify the name of the generated Application
Objects_dir =.../../obj/sp_tool/release # specify the directory where the target file (OBJ) is stored.
}
Debug {
Target = bqtool_d # specify the name of the generated Application
Objects_dir =.../../obj/sp_tool/debug # specify the directory where the target file (OBJ) is stored.
}
Moc_dir =$ {objects_dir}
Destdir =.../../bin # specify the directory where the generated application is stored