[Qt-creator] How to put individual classes to sub dir

Jakov dkymail at gmail.com
Tue Aug 24 01:49:33 CEST 2010


Dear Robert,

Could you please take a look at my thread about organizing nested
directories in the next Qt Creator release?

In short, the project tree is like that: A normal Qt Project, with a pure
directory, called Animal. I say "pure" because it's just a normal directory,
not a project directory. This dir contains 2 subdirs: Dog and Cat. Each of
them contains a Qt Class (.h, .cpp, .ui). That's all.

Current Qt Creator can't do that. The first way, Dog and Cat would be placed
at the same level with Animal. This way doesn't reflect the physical
structure. The second way, Animal has 3 nodes: Forms, Headers, and Sources.
Corresponding type of each class (form of Dog, form of Cat; header of Dog,
header of Cat, etc) would be included in those nodes. This way seems intricate,
complicated,... and not what the user expected.

I read many threads about this issue:
http://www.mail-archive.com/qt-creator@trolltech.com/msg01774.html Many
users like to have this feature.

Thank you and the Team so much!

Best regards,

Jakov

On Fri, Aug 20, 2010 at 9:03 AM, Jakov <dkymail at gmail.com> wrote:

> Hi group,
>
> I'm giving up. Is Qt Creator able to display nested directories? In theory,
> ex01.pro includes Frames/Frames.pri, then Frames.pri includes
> Frame1/Frame1.pri, and Frame2/Frame2.pri. But it doesn't work as expected.
>
> Clearly Qt Creator 2.0.0 has many more nice features as compared to 1.x.x,
> but why I still find hard to use it... My favourite IDE is C++Builder 2009,
> and now I'm moving to Qt's world. Could you give me your hands :-)
>
> Thanks and have a nice day.
>
> -- J
>
>   On Wed, Aug 18, 2010 at 2:04 PM, Jakov <dkymail at gmail.com> wrote:
>
>> Dear Adam,
>>
>> Oh no, I don't mean it. But I'm not able to find a sufficient (official?)
>> documentation about these configurations. I just try-and-error'ed.
>> If you're sure of the possibility of the expected layout above, I'll try
>> more. It's strange that I always see the Frame1 and Frame2 stay at the same
>> level with Frames as per your guide...
>>
>> Thanks and have a nice day.
>>
>> -- Jakov
>>
>>
>>   On Tue, Aug 17, 2010 at 9:48 PM, Coda Highland <coda at bobandgeorge.com>wrote:
>>
>>> You can make frames.pri include frame1.pri and frame2.pri; just take
>>> the technique I showed you and extend upon it. I knew what I was
>>> showing you didn't completely match; I'm not doing your homework for
>>> you. :P
>>>
>>> /s/ Adam
>>>
>>> On Mon, Aug 16, 2010 at 11:42 PM, Jakov <dkymail at gmail.com> wrote:
>>> > Dear Adam,
>>> >
>>> > It works! Thank you a lot!
>>> >
>>> > However, the layout is not completely as I expected. Or my expected
>>> layout
>>> > is impossible for this current Qt Creator version (2.0.0)? I'd like the
>>> > hierarchical layout should be like this:
>>> >
>>> > <Prj_root>
>>> > .....|__ Frames
>>> > ..............|__Frame1
>>> > .....................|__Forms
>>> > .............................|__frame1.ui
>>> > .....................|__Headers
>>> > .............................|__frame1.h
>>> > .....................|__Sources
>>> > .............................|__frame1.cpp
>>> > .............|__Frame2
>>> > .....................|__Forms
>>> > .............................|__frame2.ui
>>> > .....................|__Headers
>>> > .............................|__frame2.h
>>> > .....................|__Sources
>>> > .............................|__frame2.cpp
>>> > .......|__Forms
>>> > ................|__ex1.ui
>>> > .......|__Headers
>>> > ................|__ex1.h
>>> > .......|__Sources
>>> > ................|__ex1.cpp
>>> > ................|__main.cpp
>>> >
>>> >
>>> > If QtCreator supports this, it's great. And I can try another layout
>>> that I
>>> > tried some days ago, but failed:
>>> >
>>> > <Group Project>
>>> > .........|__ <Main Project>
>>> > ..................|__ main.pro
>>> > ..................|__ <other files>
>>> > .........|__ Share
>>> > ..................|__ SharedForm1
>>> > ..................|__ SharedForm2
>>> >
>>> > In which, Main Project uses SharedForm1, 2, etc.
>>> >
>>> > Thanks so much for taking time helping me.
>>> >
>>> > Best regards,
>>> >
>>> > -- Jakov
>>> >
>>> >
>>> >
>>> >
>>> > On Tue, Aug 17, 2010 at 9:19 AM, Coda Highland <coda at bobandgeorge.com>
>>> > wrote:
>>> >>
>>> >> My thought on the matter would be something like this:
>>> >>
>>> >> ex1.pro:
>>> >> include(Frames/Frames.pri)
>>> >>
>>> >> Frames/Frames.pri:
>>> >> HEADERS += Frames/Frame1/Frame1.h Frames/Frame2/Frame2.h
>>> >> SOURCES += Frames/Frame1/Frame1.cpp Frames/Frame2/Frame2.cpp
>>> >> FORMS += Frames/Frame1/Frame1.ui Frames/Frame2/Frame2.ui
>>> >>
>>> >> et cetera. Notice that you still need to use the path relative to
>>> >> ex1.pro, not to the .pri file -- this is a fairly common mistake.
>>> >>
>>> >> /s/ Adam
>>> >>
>>> >> On Mon, Aug 16, 2010 at 6:33 PM, Jakov <dkymail at gmail.com> wrote:
>>> >> > Hello Alan,
>>> >> >
>>> >> > I'm editing the pri files. I search the old archive, and find out
>>> that
>>> >> > whenever I include a .pri file, Qt Creator "creates" a virtual
>>> directory
>>> >> > (a
>>> >> > node) in the Projects window (on the left side).
>>> >> >
>>> >> > The main .pro file will include the frames.pri, so it would "create"
>>> the
>>> >> > Frames node in the window:
>>> >> > + ex1.pro: include( Frames/Frames.pri)
>>> >> > + frames.pri:
>>> >> > I think the frames.pri should do the same:
>>> >> > include(Frames/Frame1/frame1.pri), but it doesn't work... So I left
>>> >> > frames.pri empty.
>>> >> >
>>> >> > At this step, if I put a class in Frames dir, the project works
>>> fine.
>>> >> > But I
>>> >> > do want to make a lower level: adding Frame1 and Frame2 directories
>>> >> > (which
>>> >> > include their own classes) within Frames.
>>> >> >
>>> >> > There's no link line yet, Alan.
>>> >> >
>>> >> > Thanks for your quick reply!
>>> >> >
>>> >> > Jakov
>>> >> >
>>> >> >
>>> >> > On Tue, Aug 17, 2010 at 6:20 AM, <alan.westbrook at nokia.com> wrote:
>>> >> >>
>>> >> >> Ahh, I see.
>>> >> >> What does the first .pri file look like?
>>> >> >> Do you see the frame.cpp files compile from the compiler output?
>>> >> >> What does your link line look like?
>>> >> >> Alan
>>> >> >> On Aug 16, 2010, at 3:54 PM, ext Jakov wrote:
>>> >> >>
>>> >> >> Dear Adam,
>>> >> >>
>>> >> >> Thanks for your reply. I remove the subdirs already, to make it a
>>> >> >> normal
>>> >> >> app project. I "try-and-error" many ways, but the layout is not as
>>> >> >> expected.
>>> >> >> Could you please suggest me the config or give me the document of
>>> using
>>> >> >> .pro
>>> >> >> and .pri file? The idea is, I want to group individual classes (.h,
>>> >> >> .cpp,
>>> >> >> .ui) in a separate directory (to have a better look, easy to
>>> >> >> find/edit/manage...) within the main project dir, or even at the
>>> same
>>> >> >> directory level with main project dir.
>>> >> >>
>>> >> >> I'd like to thank Alan, but there's no libs yet. They're just pure
>>> UI
>>> >> >> classes, just at lower directory level, as compared to main project
>>> >> >> directory. I'll not include every single .h, .cpp, and .ui in the
>>> >> >> HEADERS,
>>> >> >> SOURCES, FORMS in the main .pro, as those files will be included in
>>> >> >> corresponding nodes (Headers, Sources, Forms) separately.
>>> >> >>
>>> >> >> I'm looking forward to your guide... In the meantime, I'll
>>> try-'n-error
>>> >> >> again. I look at demo and examples in Qt SDK, but there's no
>>> helpful
>>> >> >> examples... Thank you again.
>>> >> >>
>>> >> >> BR,
>>> >> >> Jakov
>>> >> >>
>>> >> >>
>>> >> >> On Mon, Aug 16, 2010 at 9:31 PM, Coda Highland <
>>> coda at bobandgeorge.com>
>>> >> >> wrote:
>>> >> >>>
>>> >> >>>  First off, don't use a subdirs project for that. Just use a
>>> normal
>>> >> >>> "app" project and use relative paths in the .pro file. If you want
>>> to
>>> >> >>> organize the .pro file you can use include() with some .pri files
>>> --
>>> >> >>> Creator knows how to sort this out. (Note that .pri files consider
>>> >> >>> paths relative to the main .pro file, not to itself.)
>>> >> >>>
>>> >> >>> Second, "INCLUDEPATH += Frames" in the main .pro file (or possibly
>>> in
>>> >> >>> frames.pri) so that "Frame1/Frame1.h" can be found inside of the
>>> >> >>> "Frames" directory.
>>> >> >>>
>>> >> >>> /s/ Adam
>>> >> >>>
>>> >> >>> On Mon, Aug 16, 2010 at 8:51 AM, Jakov <dkymail at gmail.com> wrote:
>>> >> >>> > Hello Group,
>>> >> >>> >
>>> >> >>> > I have a question about organizing subdir/nested classes in Qt
>>> >> >>> > Creator.
>>> >> >>> > I
>>> >> >>> > intend to use dozens classes (inherit from QFrame), to be
>>> promoted
>>> >> >>> > later. I
>>> >> >>> > want to have each of them grouped in a separate folder (dir).
>>> Like
>>> >> >>> > this:
>>> >> >>> >
>>> >> >>> > <PROJECT_ROOT>
>>> >> >>> > ----- Frames
>>> >> >>> > --------- - frames.pro
>>> >> >>> > --------- - Frame1
>>> >> >>> > ---------------- frame1.h
>>> >> >>> > ---------------- frame1.cpp
>>> >> >>> > ---------------- frame1.ui
>>> >> >>> > ---------------- frame1.pri
>>> >> >>> > -------- - Frame2
>>> >> >>> > ---------------- frame2.h
>>> >> >>> > ---------------- frame2.cpp
>>> >> >>> > ---------------- frame2.ui
>>> >> >>> > ---------------- frame2.pri
>>> >> >>> > ----- ex1.pro
>>> >> >>> > ----- ex1.h
>>> >> >>> > ----- ex2.cpp
>>> >> >>> >
>>> >> >>> > File frame?.pri indicates HEADERS, SOURCES, FORMS
>>> >> >>> > File frames.pro simply includes those *.pri files.
>>> >> >>> > File ex1.pro:
>>> >> >>> > + TEMPLATE = app subdirs
>>> >> >>> > + SUBDIRS     += Frames
>>> >> >>> >
>>> >> >>> > That's it. The problem comes when I'm trying to use frame1,
>>> frame2
>>> >> >>> > in
>>> >> >>> > the
>>> >> >>> > main project (ex1). Although I specify INCLUDEPATH +=
>>> Frames/Frame1
>>> >> >>> > in
>>> >> >>> > the
>>> >> >>> > ex1.pro, ex1 can "see" frame1.h, but it doesn't know about
>>> >> >>> > frame1.cpp,
>>> >> >>> > so an
>>> >> >>> > error thrown: undefined reference to
>>> `TFrame1::TFrame1(QWidget*)'
>>> >> >>> >
>>> >> >>> > I'll try to summary the problem: how to put individual classes
>>> in
>>> >> >>> > subdir
>>> >> >>> > freely?
>>> >> >>> >
>>> >> >>> > Please help me.
>>> >> >>> >
>>> >> >>> > Thank you in advance!!!
>>> >> >>> >
>>> >> >>> > Best regards,
>>> >> >>> >
>>> >> >>> > Jakov
>>> >> >>> >
>>> >> >>> > _______________________________________________
>>> >> >>> > Qt-creator mailing list
>>> >> >>> > Qt-creator at trolltech.com
>>> >> >>> > http://lists.trolltech.com/mailman/listinfo/qt-creator
>>> >> >>> >
>>> >> >>> >
>>> >> >>>
>>> >> >>> _______________________________________________
>>> >> >>> Qt-creator mailing list
>>> >> >>> Qt-creator at trolltech.com
>>> >> >>> http://lists.trolltech.com/mailman/listinfo/qt-creator
>>> >> >>
>>> >> >> <ATT00001..txt>
>>> >> >>
>>> >> >> _______________________________________________
>>> >> >> Qt-creator mailing list
>>> >> >> Qt-creator at trolltech.com
>>> >> >> http://lists.trolltech.com/mailman/listinfo/qt-creator
>>> >> >>
>>> >> >
>>> >> >
>>> >> > _______________________________________________
>>> >> > Qt-creator mailing list
>>> >> > Qt-creator at trolltech.com
>>> >> > http://lists.trolltech.com/mailman/listinfo/qt-creator
>>> >> >
>>> >> >
>>> >>
>>> >> _______________________________________________
>>> >> Qt-creator mailing list
>>> >> Qt-creator at trolltech.com
>>> >> http://lists.trolltech.com/mailman/listinfo/qt-creator
>>> >
>>> >
>>> > _______________________________________________
>>> > Qt-creator mailing list
>>> > Qt-creator at trolltech.com
>>> > http://lists.trolltech.com/mailman/listinfo/qt-creator
>>> >
>>> >
>>>
>>> _______________________________________________
>>> Qt-creator mailing list
>>> Qt-creator at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-creator
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20100824/ebbe26f8/attachment.html 


More information about the Qt-creator-old mailing list