Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qml vs c++ for overall UX?



  • Hi,
    I am diving into QT again, after some work done in other frameworks like React Native and Nativescript.
    But I am a C++ programmer and love that language. I am bored of JS.

    So I decided to give QT a shot for my next Xplatform project.
    I understand we have QML, but I get that it comes with javascript.
    I am concerned about perfs, app size and loading time.

    In 2019, is coding the app in full c++ a better take for performance and smoothness or is qml faster?
    Are we concerned about the data exchange performance hit with java/swift in c++? Does it happen in qml?

    I am experienced in C++, so dev time is not a concern here.
    What are your experiences about this?

    Thanks


  • Lifetime Qt Champion

    Hi and welcome back !

    It depends a bit on what you are developing for.

    If a classic desktop application then widgets are perfectly fine.

    If you are targeting mobile then QtQuick will be better. Same as if you want dynamic UIs with effects and that kind of stuff.

    The heavy lifting you can still do in C++ though.

    Performance and memory wise, there have been lots of improvements with the latest releases.



  • Thanks SGaist,

    I develop for mobiles.

    So I have to embed javascript anyway (JS<->QML), right?

    Edit: official doc
    Apparently not, but I would like to be sure that JS engine is not embedded that way :)


  • Lifetime Qt Champion

    QML is javascript based yes but you already have all the plumbing provided.


  • Moderators

    @JulienD I wouldn't necessarily categorize QWidget-> Desktop & QML -> Mobile.

    I've done both for both systems. And both work great.

    It's more a question of style and time. It is very easy to make animations of all kinds, to load and place Images where ever you like etc. Also QML comes with native OpenGl support.
    Which makes it indeed a good idea for mobile platforms.

    However if you plan to do a simple ui, some buttons switches texts, etc QWidgets will do just fine.
    You can do everything in QWidgets what you can do in QML, however you'll spend more time setting it up and doing it.

    Qt & QML delivers its very own and tailored JavaScript Host Environment, you as programmer won't have to do anything to set it up.
    More information here

    In the end, as you have experience with c++ and JS I would suggest QML, that way you have basically 4 Languages combined to do what every you fancy.
    c++(the backbone)
    QML(the visuals)
    JS(Object, Array, and Math, properties)
    HTML (this one is a stretch, I only mention it in case you want to make use of the 2d Canvas in QML)



  • @J.Hilk Thank you for your input!

    I will give it a try and come back on this forum if stuck ;)
    Cheers,