Using .pri files in Qt

My guess from looking at your screenshot is that QtCreator doesn't find the header files listed in the .pri file. If your .pri file is located in a different directory than your .pro file (which seems to be the case here), Qt looks for the files listed in the .pri file in the same directory as the .pri file (not the .pro file), and any relative path will be resolved from that directory.

When a file can't be found, QtCreator silently ignores it and simply doesn't add it to the folder in the projects view. If, for example, you used the full path for line.h, circle.h and bezier.h in your include.pri file, as soon as you save the file, you'll see them appear in the projects view. The key now is simply to figure out what is the appropriate relative path pointing to those files relative to the .pri file.


The format of the .pri files is exactly the same as the format of the .pro files. The main difference is one of intent; a .pro is what most people would expect to run qmake on directly, while a .pri is to be included by a .pro. When you instruct qmake to include another file, it just processes the commands in that file as if it were in the current file.

The last time I looked at Qt Creator, it would do additional parsing and recognize that .pri files were separate, and list any headers/sources/ui/rc/pri files from that file specifically as a subdirectory, much like you see the include.pri files listed in the screenshot of this question.

Tags:

Qt

Qt Creator