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

MV Pattern and many models



  • Hi,

    Recently I'm trying to implement application which uses many models and many views which uses the same data.
    Currently I have 2 models - one is QTreeView and the other is used by some labels and other widgets. Now when I'm adding nodes to tree I have:

    UI input -> append nodes to data -> inform model that data changed (by sending position of new nodes addition and new nodes) - currently model have other tree structure (which encapsulates data) cause I have to call beginInsertRows and endInsertRows when I'm appending data to model.

    My question: is there a better solution for having multiple models which uses the same data? I can't find any article describing this problem.

    PS if there is something unclear I will try to explain it.

    Regards.


  • Lifetime Qt Champion

    Hi,

    Depending on your needs, you would usually have a base model that interacts with your data and then as needed proxy models that would transform the data the way you need them.


Log in to reply