This is a followup to this question How to create a subdirectory for a project in qt-creator?, where the first answer didn't work for me.
I resolved it by manually writing every file into the main .pro file, which is not that much harder, but I still wonder - how exactly .pri files work, and why the solution linked above didn't add the folders, but only the .pri files, so it looked like this in Qt creator:
So, my questions are:
This is usually called Project Include File.
qmake provides a number of built-in functions to enable the contents of variables to be processed. The most commonly used function in simple project files is the include() function which takes a filename as an argument.
The behavior of qmake can be customized when it is run by specifying various options on the command line. These allow the build process to be fine-tuned, provide useful diagnostic information, and can be used to specify the target platform for your project.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With