Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Philosophical question on QML / C++ split
For "non-trivial" applications, you'd want a solution that minimizes the amount of code you have to write, and is easy to maintain. A good rule of thumb is to use each language for the purpose it was designed for.
martin_ky last edited by
For any reasonably complex application I tend to write as much as possible in C++ and expose the "business model" via QObjects. Keeping only essential UI stuff in QML and hook it to the C++ model (eg. state changes to model property changes, etc).
If you need complex UI behavior and need to store UI releated data for your C++ model somewhere, and don't want to pollute your business model with UI stuff, maybe write a proxy model (also in C++) and put it there.
I tend to prefer C++ over QML mostly because I am much more comfortable with C++. But things said in previous posts also apply: C++ is better in structuring your code. My experience is, that QML files tend to grow big and messy, even if you split into components. My main.qml is always the messiest one, with all the global states and transitions.
To get further ideas, I recommend to watch "this video from Qt Dev Days 2012":http://www.youtube.com/watch?v=kvWeE3kurEQ It is the best example I've found so far, of how QML scales in realistically comlex applications.
Thanks for your answers they are very helpful
@martin_ky - I have found the same thing, it's easy to write specify complex behaviour with QML however I have found that the QML files do not scale very well and there seems to be no constructs to allow me to create a manageable system with a large amount of QML code; hence using C++ for a lot of it. Thanks for the video link.