Qt uses a modular construction .pri

introduction

 When you plan to use Qt to develop a new GUI program, open to create a GUI IDE project, you will see the following engineering structures.
pro
There have their own hierarchical file, .h exist in Headers, .cpp present in the Sources, .ui exist in Forms, .pro the management of the entire project, clear and simple structure.
 To this point you add a new file to the project, is also very simple, right-engineering options will be added, you just need to follow the prompts to go step by step down, you can join the project required documents.
add
 When your project file is increased, the logical structure of your project will become relatively complex, then point to open your project node discovers all nodes under such a long string, file what modules are crowded into a node under very bloated.
tree
 And manages that usually do not need to be concerned about the .pro file structure of the project, when you project becomes larger, you have to need to pay attention to it, understand it, change it.

Reform

 Here do not introduce any complicated skills. .Pri to simply talk about the use of modular construction.

Modular engineering using .pri

 .pri (.pro, project include) can be seen as a subset .pro file, the contents of which are substantially the same and .pro.
 Take for example the following works, which I will propose to the QCustomPlot module,
 before modular, under HEADERS variable .pro file like this,
1
 project structure drawing is,
2
 actual disk folder,
The actual file directory

 Reconstruction is very simple,
 in the project directory to build a folder named your module name, then move the file qcustomplot related modules into account, then create a qcustomplot.pri file.

 qcustomplot.pri added in the related documents may be added right into the IDE operation may edit the code into a file in FIG .pri in.
2
 Next, the project .pro file, the original qcustomplot relevant code removed (because qcustomplot under your project directory path of the original has been removed at this time, it is a waste code), then the following code to the .pro,

INCLUDEPATH += $$PWD/qcustomplot	# 工程编译时,会去INCLUDEPATH列表下的目录搜索文件
include     ($$PWD/qcustomplot/qcustomplot.pri)	# include()包含的文件会显示在工程结构图中

 After loading, look at FIG engineering structures,
4
case, qcustomplot module has separate out, and the physical structure and logical structure corresponds to engineering. Related documents are placed in each module the respective module structure. The whole project is a clear structure a lot.

end

 Write a .pro file can help you to sort out very structure of the project components, but also to make people familiar with the project to take over sooner framework of the project, a good framework for the development and maintenance often has a multiplier effect.

Published 60 original articles · won praise 18 · views 20000 +

Guess you like

Origin blog.csdn.net/BadAyase/article/details/103767431