Search code examples
c++qtc++11structureqwidget

Structure of bigger project in C++/QT


I'm planning to start a medium-sized hobby project in C++/Qt. I would like to try making music player with some advanced features like music library, ID3 tag editor and basic support to receive streams (think of crossover of WinAmp and VLC).

I can design the whole thing in QtCreator to one ui file, but then I would get one huge class, which is certainly not nice.

Or I can design each element of the GUI as one widget, each in its ui file. Each ui file would then have one worker class and I would create the hiearchy of widgets using layouts.

The second solution seems to be nice, but I am afraid of things like handling window resize.

What are the best practices when making more complex application when using Qt? Can you recommend me an article or an open-source project I can learn from?

Thanks for all suggestions!


Solution

  • Bigger UI/GUI projects are not simple UI files, but more common are 'ui build from code'.

    Imagine some thing like:

    .
    └── MyProject
        ├── CoreSystem \ *.cpp *.h
        ├── MusicControler \ *.cpp *.h
        └── UI
            ├── CoreUi \ *.cpp *.h
            └── MusicUI
                ├── PlayListUI \ *.cpp *.h
                └── EqUI \ *.cpp *.h
    

    And more, and more.

    Idea is just to separate some 'parts' of program to smaller chunks, in this way you have more control how they look, and how they work.

    Using Qt signal/slot system you can separate more and more, including some design patterns you can expand your project to additional functionality, like plugins?

    This must be view from bigger scope, to figure out what UI parts will be, what 'core' (back-end engine) function must have, and many other things.

    For example 'skins' - they must be placed somewhere, skins mus have some variables to setup + some parser? (easier is just use 'coded' css names).

    Is really hard what exactly you need, but most of UI from app is not UI files that are designed in QtCreator, but made manually from code.

    If you really like to create UI in editor, then use QStackedWidget.