[Qt-interest] How does QtCreator parse the .pro file

Bo Thorsen bo at fioniasoftware.dk
Wed Sep 7 14:56:53 CEST 2011


Den 07-09-2011 14:26, Vannoote, Frederik skrev:
> My pri files are written like that, but the pro file isn't, mainly because QtCreator does that for us. The pri files are maintained by hand.
>
> Is there a way to let QtCreator do this?

No. Instead, you should move all the things from the pro file that are 
shared between your app pro and your test pro to a shared.pri, and 
include that from the two pro files.

This works for me because I pretty much only have stuff like symbian 
setup and the main.cpp file in the pro file. Everything else is moved to 
subdirs and handled in pri files. For example, I nearly always have ui 
and model subdirs.

I hope this helps,

Bo.

> -----Original Message-----
> From: Bo Thorsen [mailto:bo at sonofthor.dk] On Behalf Of Bo Thorsen
> Sent: woensdag 7 september 2011 13:46
> To: Vannoote, Frederik
> Cc: qt-interest at qt.nokia.com
> Subject: Re: [Qt-interest] How does QtCreator parse the .pro file
>
> Den 07-09-2011 13:32, Vannoote, Frederik skrev:
>> Hi all,
>>
>> I'm using QtCreator as IDE. My application has next to the sources also
>> some unit tests using QTestLib.
>>
>> My goal is to be able to debug and step through the classes when running
>> a unit test.
>>
>> This is my directory structure:
>>
>> -source
>>
>> oproject.pro
>>
>> ocomponents
>>
>> §comp1.pri
>>
>> §comp2.pri
>>
>> osome other classes
>>
>> -tests
>>
>> ounittests.pro
>>
>>   From the unittests.pro I want to include the project.pro. I do this
>> using the regular include(../source/project.pro) statement. However the
>> paths are not correct. To cover that, I prepend ../source to them using
>> some qmake functions.
>>
>> At this point that is working fine. I can compile my unittests using the
>> command line.
>>
>> However, when included in QtCreator, it only lists the .pri and .pro
>> files without the headers and sources.
>>
>> Due to that, my code completion don't work, nor can I put breakpoints.
>>
>> How can I overcome this?
>>
>> Is this the correct approach to do these kind of things?
>
> You have to do two things:
>
> In the .pri file, do this:
>
> SOURCES += \
>     $$PWD/file.cpp ...
>
> Always use the $$PWD in included pri files from other directories
>
> Usually, I place the directories as subdirs of the one that hold the
> .pro file(s) because then I can use #include "subdir/file.h". If you
> prefer, you can add the subdirs to the include path by adding
>
> INCLUDEPATH += $$PWD
>
> in the .pri file.
>
> One final thing: You *can not* have two files with the same names in
> different directories when you are using pri files as subprojects
> because the generated .o files are all placed in the same directory.
>
> Bo Thorsen,
> Fionia Software.
>


Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk



More information about the Qt-interest-old mailing list