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

I need an example for MVVM architecture, where the view is in QML and MODEL, VIEWMODEL in CPP. I want to understand how it works.



  • I am trying to understand MVVM architecture and I need a good example code so that I have a clear understanding of how the architecture actually works . Any kind of help will be greatly appreciated, Thank you in advance.


  • Lifetime Qt Champion

    Hi,

    From the looks of it, you do not need MVVM using Qt Quick and C++ models. QtQuick already provides the binding part and does not require you to write business logic unless you want to.



  • @SGaist hello, I have worked with model view architecture before and integrated CPP and QML and it worked fine, but I want to know how to develop the communication using MVVM architecture.


  • Qt Champions 2017

    It is hard to give such an ready made example.
    Just give high level view

    1. ViewModel(C++ class) provides the data bindings directly to View(QML)
    2. Model may be simple c++ class, gets the data from appropriate sources & keeps it. This may or may not be Qt Model.
    3. ViewModel get the only required data from Model. It may apply filters or format it or convert & makes it presentable to view directly using the bindings.

Log in to reply