Qt Designer C++ or QML for GUI [closed]

I know that the use of QML is quite new in Qt and I was wondering if I should design my application using Qt Designer or QML. I will be using a MVC pattern and my main concern if I use QML for the GUI is that it might not be easy to integrate inside the rest of my C++ app.

Feel free to give your personal advice, I would greatly appreciate it. Thank you!


Solution 1:

QML is primarily intended for mobile platforms. Due to its youth and its concern for varied platform interface conventions, it lacks standard controls like buttons and combo boxes (but see the Components project). If you're on mobile, or your UI requires a highly customized visual style, QML might be worth considering. Be prepared for a lot of extra work in designing custom controls. Integrating QML and C++ is still pretty rough in my opinion. I would personally recommend using QML only for simpler apps, only on mobile platforms, and only with JavaScript. Under the right circumstances I might consider writing custom QML elements in C++.

Qt's C++ API isn't going away anytime soon. It's also designed with the desktop in mind and will do a better job of meeting user expectations on desktop platforms. If you're on the desktop, I would recommend sticking to C++ and Designer. Even after QML matures a bit, it probably won't be the right solution for most desktop apps.

Update!

It looks like things are beginning to change. I haven't tried the new components myself yet, and documentation seems a little sparse (or at least, out of the way), but this could eventually remove the greatest barrier to using QML on the desktop. It remains to be seen whether this will get support in the long term, but if you're willing to accept the risk of being an early adopter, I think QML may now be a viable choice for desktop apps.

Solution 2:

It'd be worth trying a bit of QML to test whether it suits your needs.

If you are building a highly custom UI with dynamic interfaces and animations then QML fits the job; if you are building a traditional desktop application then you will probably want to stick with the Qt C++ API.

In regards to integration between QML and C++, QML is designed to be easily integrated with C++ code, and many QML applications use some sort of C++ backend. It is straightforward to inject C++ objects into a QML interface, or write custom QML elements in C++. Have a look at http://doc.qt.io/archives/qt-4.7/qtbinding.html and http://doc.qt.io/archives/qt-4.7/qml-extending-tutorial-index.html.

Solution 3:

One thing missed by the above answers is that QML has the added advantage/disadvantage of JavaScript for business logic (if needed). I am currently building a (small to medium) sized application for the desktop and right now my (2) alpha users enjoy it. I'm impressed with the expressiveness of the framework and how quickly I can get it up and tested. All in all I find it faster to work with than a RAD editor (designer) and I enjoy having JavaScript as a fallback on my UI when I'm doing annoying things like hovers/validation etc...

I think it is a matter of how comfortable you are with the language. If C++ is your "go to" language than you'll probably favor the designer. If you're coming from the Web (confession, I'm a Java EE engineer/MVC .NET dev doing a lot of front end) you'll find it refreshing and fast.

It also allows for some responsiveness that users expect these days. Overall I'd give it a huge plus. Give it a try--you'll probably be rather please and rather annoyed in the same time frame. I'm still angry about a couple things (FileIO in particular) but I've been enjoying the GUI side of things in a way I rarely do on the desktop.