50

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!

2

3 Answers 3

47

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.

8
  • 10
    I see QML as a cross-platform (and entirely more readable!) version of WPF/XAML. There's nothing at all that makes it mobile specific.
    – Dynite
    Feb 22, 2011 at 13:27
  • @Dynite: Not inherently, but mobile is what Nokia is (was?) pushing it for, and that's where it's currently most comfortable. For example, the standard QML components are designed for touch-screens rather than mice.
    – Steve S
    Feb 22, 2011 at 15:32
  • Also, from doc.qt.nokia.com/4.7-snapshot/qtquick.html -- "Qt Quick is a collection of technologies that are designed to help developers create the kind of intuitive, modern-looking, fluid user interfaces that are increasingly used on mobile phones, media players, set-top boxes and other portable devices." (emphasis added)
    – Steve S
    Feb 22, 2011 at 15:33
  • 1
    @Steve "that's where it's currently most comfortable". I don't think that is substantiated by the facts. The text you've pasted is just marketing material to show that is can be used anywhere.
    – Dynite
    Feb 22, 2011 at 15:37
  • 1
    This answer may be edited to reflect the fact that it is nos easy to mix Qt C++ API with QML (in both ways). So, for desktop, you can start with an upper level C++ Widgets, and inside it, add some part designed with QML if you need beautiful, fancy stuff.
    – Korchkidu
    Dec 20, 2013 at 7:28
15

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.

13

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.