Qml or c++ or both

  • I use qt since 1997 (version 0.6 can not remember), now I'm studying QML, but I still have not clear ideas about it. What is the ideal use? Graphics with QML and logic with C + +? QML only for simple mobile application? Use C ++ only for performance? It 'can hope to Pugin QML for browsers?

  • It depends on your use-case. You could think of it as a presentation-layer for your App where the business logic is in C++ - or where high performance computation/graphics are written in C++. You can also use JavaScript for simple imperative code. QML can be used both for simple and complex applications - again it depends on your use-case. There is no QtDeclarative plugin for browser in Qt.

  • We use QML with C++ to make a desktop app that looks and behave like those web 2.0 apps. It's very powerful. All the logic is done in C++, and all the graphics in QML.

    I think the ideal use for desktop apps is:

    1. You want a beautiful interface

    2. With lots of effects and animations

    3. That looks the same on all platforms

    4. And that doesn't use the native widgets.

    So anything that should look like a web app or an iPhone / iPad app qualifies pretty well.

    Look at Spotify, for example (http://spotify.com/). That's the kind of interface that is easier to achieve in QML than in pure C++.

  • Its easier to get consistent looking UI for multiple screen sizes if you use layouts in C++ .

    But for fixed screen sizes i guess QML is really wonderful.

  • @gregschlom: Well, I think that some parts are harder to accomplish with QML, for example, treeviews/tableviews with headers. Can you do them in QML w/o to much hack (or is it possible at all)?

    But when it comes to doing delegates for listviews nothing beats QML :)

    Hmm, you could still have an hybrid QML/Widget app though with the best from both worlds.

  • We are using C++ and Qml together. Only Qml will not provide a lot of functionality for you, but together with C++ it will give a lot of power.

    mario, I've treeview qml implementation with not a big hack, but it supports only trees with not too many children. If you can read russian you can read it in my blog (in my profile).

  • @archerabi: I don't have a lot of experience with layouts, but I would say the anchoring system in QML is powerful enough to make it easy to deal with different screen sizes.

    @mario: haven't tried to make list views with headers, but we did re-implemented our own list view component as QML's default one wasn't suiting our needs. So the bottom line is that it's really easy to extend QML, and with a few (ok, maybe a hundred or so) lines of C++ code, you can get exactly what you want.

    But yes, it's not for any project. It's more suited for projects with a strong focus on fluid user interface.

  • Denis, Looks good! I don't know Russian but I understand code and the screenshot :)

    Do you have the code downloadable somewhere (I guess it's free to use)? I'm to lazy to copy&paste it from the webpage :)

    gregschlom, I agree, it's very easy to extend and I love the way how you do UIs with QML. But sometime it's hard to go from Widget-based UIs with a large portfolio of components (like comboboxes with completion) to nearly start from scratch. I think I have to change my mindset when building UIs with QML :)

  • mario, yeah, I've uploaded this example to our lug server and you can download it "here":http://dl.yarlug.org/devel/Qt/qmlTreeModel.tar.gz .

Log in to reply