[Solved] Organizing source files



  • Hi all

    I am wondering how I can make folders in Qt creator... I have a lot of .cpp and .h files and and I want to organize them in folders i.e every thing in my Resource layer should be in a folder named Resource, folder called Business for the files belonging to the business layer etc.

    something like this:

    Headers
    - Business
    business.h
    - Resource
    resource.h
    - Views
    viewa.h
    - ...

    Sources
    - Business
    business.cpp
    - Resource
    resource.cpp
    - Views
    viewa.cpp
    - ...

    How can I do this ? Am I that blind that I cant find a solution for this ?

    Is there a plugin which allows me to right click on fx the Sources folder and -> new -> folder ?

    BR
    DarkRoast



  • take a look at how the Qt SDK sources are organized



  • [quote author="chetankjain" date="1298725888"]take a look at how the Qt SDK sources are organized[/quote]

    Maybe I haven't been clear or I am misunderstanding your post. In Visual Studio It is really easy to make folders in your project and organize your source code in those folders...

    At the moment Qt creator only separates the headers, sources and resources files into folders. I want to make my own folders i.e Business folder and put my business code there and etc.

    chetankjain can you show an example on how to do this ?

    BR
    DarkRoast



  • ah apologies, I misunderstood your question. I thought you were seeking information on how to organize sources into subfolders in your project and so asked you to look into the Qt sources organization.

    what you seek is probably not going to be addressed by the creator team .. take a look at these:
    "http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3265":http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3265
    "http://bugreports.qt.nokia.com/browse/QTCREATORBUG-902":http://bugreports.qt.nokia.com/browse/QTCREATORBUG-902



  • [quote author="chetankjain" date="1298728689"]
    what you seek is probably not going to be addressed by the creator team .. take a look at these:
    "http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3265":http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3265
    "http://bugreports.qt.nokia.com/browse/QTCREATORBUG-902":http://bugreports.qt.nokia.com/browse/QTCREATORBUG-902
    [/quote]

    Hmmm dt answers like this:

    bq. We aren't a file browser.

    and

    bq. We don't believe that adding file system actions to the project tree is the right place. The project tree doesn't show a 1:1 mapping to the file system and as such is not really suited for that. E.g. you wouldn't see a newly created dir in the project structure.

    I really disagree... I want to create folders in my project tree in Qt creator and organize my source files, just like in visual studio. i.e I want to create a folder called fx. views and then I should bee able to right click on that and create a new class, .cpp or .h and these files will be in the views folder. And of course Qt creator would also create the folder and etc. in the project folder and update the .pro file so everything would compile...

    I find this a very basic feature which helps allot in keeping large projects with many source files organized.

    Its very hard to find files you need, when you only have a folder for the sources and headers. It gets very frustrating when you have 50+ .cpp and .h files...

    How do people using Qt creator manage all their source file in large projects ?

    BR
    DarkRoast



  • good points DarkRoast, and having used various IDE's over time myself, I understand what you mean.
    Unfortunately there is no "Postponed" state or the likes in Qt bug tracker and I find many times bugs are closed as "out of scope at present".
    You could try to reopen the above bugs and vote for it. Other interested developers could also vote for its priority and if sufficient votes are there, who knows it might just get taken up. Or someone from community could contribute ...



  • I really like working in Qt creator, its a very good IDE. But it really bugs me that Qt creator does not have this basic feature...



  • I work only with Qt creator for coding in Qt :) and it is evolving continuously which is good



  • [quote author="chetankjain" date="1298732843"]I work only with Qt creator for coding in Qt :) and it is evolving continuously which is good[/quote]

    I wonder how much Qtcreator evolving is going on now in the Qt department ...? Now when Nokia has sold its soul to Microsoft.



  • there have been many varying blog posts and comments on this topic ... but as far as I know, no announcement made so far about ramping down efforts on Qt. And its just a partnership with MS and not a sale :) ... so I'm not really worried about Qt dying. There is also the community to further support Qt under any circumstance


  • Moderators

    The project viewer is meant to visualize the project structure, not the locations in a file system. It is not a file system browser. Feel free to use that instead if you want to see your files grouped by location in the filesystem.

    If you are using qmake to build your sources you can structure the project tree by introducing .pri files. The project viewer does group files based on which pro/pri file they belong to. Visualizing the project structure is what it is supposed to do after all.

    Just open Qt Creator's pro file for an example on how that looks.

    I basically do all my navigation by using the F2, F4 and Ctrl-K key combos. Especially the last one (locator) is really powerful and gets me to classes, methods, files, etc. without having to bother about where the code is located in the filesystem/project structure.



  • Thank you very much Tobias!

    .pri files do exactly what I need :) This is what I did:

    .pro:
    @.
    .
    .
    include(Business.pri)
    .@

    The .pri file:

    @INCLUPATH += Business # Creates the folder Business in project tree

    SOURCES += business.cpp \ # Creates a folder Sources in the Business folder

    HEADERS += business.h # Creates a folder Headers in the business folder @

    This way I can organize and sort my .cpp an .h files :)

    Thanks!
    DarkRoast



  • you should've looked at how the Qt sources are organized to find it out by yourself :)
    Tobias is our Creator Guru :D


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.