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

QML vs QWidget für Machine HMI



  • Hallo,

    I am currently starting to port a proprietary hmi solution for a machine software to Qt. The machine software is programmed with Beckhoff Twincat 3 PLC which has a rather nice API to retrieve data in a binary form (data that should be visualized).
    Via code generation I can already create binary equivalent structs in C++ and in that way get data from the PLC to C++, e.g. there is data that should be visualized spread over 50+ structs. I can already read them from the PLC and have this data available in C++. I also already generate wrapper classes for these structs and for every value I want to visualize I also have a Q_PROPERTY including notifications when values within these structs change. Hence, it is rather easy to visualize the data in QML or in QWidgets.

    Now to my question...
    The structs that get generated and hence, the names of the Q_PROPERTYs will change over time. With QWidgets I can get compile time information if some data has gone, from how I understand it, with QML I don’t? However, with QML I can create much more pleasing UIs. Should I rather go with QWidgets or is there any way to deal with API changes in my C++ code within QML - maybe a tool that can check for missing or renamed properties. Is there a way to make sure that my QML user interface is actually working as it is supposed to?

    Thanks in advance,
    Stefan


  • Moderators

    @stefan-b said in QML vs QWidget für Machine HMI:

    The structs that get generated and hence, the names of the Q_PROPERTYs will change over time. With QWidgets I can get compile time information if some data has gone

    Does that mean you will recompile new versions of the app over time? Or do you need your app to adapt to new structs without recompilation?

    With QWidgets I can get compile time information if some data has gone, from how I understand it, with QML I don’t? However, with QML I can create much more pleasing UIs. Should I rather go with QWidgets or is there any way to deal with API changes in my C++ code within QML

    You can use QML to create the HMI and use C++ to handle the data. You can communicate between C++ code and QML code. For example, see From the C++ side, you can register types to become available to QML. For example, see https://doc.qt.io/qt-5/qqmlengine.html#qmlRegisterType

    Is there a way to make sure that my QML user interface is actually working as it is supposed to?

    Unit testing is normallt used to check this kind of thing.


Log in to reply