Qt: * .pro vs * .pri

What is the difference between *.pro and *.pri configuration files for qmake?

What should be done in the * .pro file and what should be done in the * .pri file?

+72
qt qmake qtcore
Dec 02 2018-11-12T00:
source share
3 answers

A .pro file is what you launched QMake. The .pri file .pri included in the .pro file. In addition, there is not much difference between them.

An example of use may be if you have different assemblies that require different parameters. You can put general information in .pro, while at the same time deferring options to various .pri files. A bit more information, although admittedly no more, can be found here .

+39
Dec 02 '11 at 15:31
source share

There is one major difference between reusing them:

.pro

This is usually called a project file.

.When

This is usually called the Include project.

As you can see in your names, the main difference is that .pri files are for including files. This is similar to including modules in a programming language for sharing functionality.

You will be able to write general settings and code into those .pri files and include them from several .pro files as needed. Here's how you could use it in practice:

foo.pri

 FOO = BAR 

hello.pro

 ... include($$PWD/foo.pri) ... 

world.pro

 ... include($$PWD/foo.pri) ... 

Thus, the community will be available both in hello.pro and in world.pro . This is not a big deal in this scenario, but when the overall functionality gets longer, it will save you some recording, as well as synchronization, bug fixing, etc.

You can even include the .pri file in another .pri file if you want. You can also include .pri files in different subprojects, etc. It is very nice.

The syntax is the same for .pro and .pri . In the end, you run qmake in .pro files, and this is also what qmake generates for you if you don't have a project file and you intend to use qmake -project .

Read more about the include function here :

include (file name)

Includes the contents of the file specified in the file name in the current project in the place where it is included. This function succeeds if the file name is included; otherwise it fails. The included file is processed immediately.

You can check if this file has been included using this function as a condition for the region.

To be complete, there are also .prf Project Feature Files and .prl Project Linker Files, but as an end user, you do not need to do this at the moment.

+59
May 24 '14 at 13:38
source share

The .pri file .pri exactly matches the .pro file format. The main difference is one of intentions; a.pro is what most people would expect to run qmake directly, while .pri should be included in .pro. When you tell qmake to include another file, it simply processes the commands in that file as if they were in the current file.

Help: *. pro vs * .pri

+15
Dec 02 '11 at 15:37
source share



All Articles