Nested list in qml: data models in models

后端 未结 2 433
死守一世寂寞
死守一世寂寞 2021-02-09 23:47

I am trying to implement a nested comment system in a QML interface. I have a model in C++ (subclassed from QAbstractListModel) in which each item in the model returns two value

2条回答
  •  天涯浪人
    2021-02-10 00:35

    I have found this very useful article that helped to solve the problem https://lemirep.wordpress.com/2013/04/06/a-practical-case-exposing-qt-c-models-to-qml/. The approach consists into creating another ListModel (derived from QAbstracListModel) inside the model class. In my example, I replace QVariantMap dataMap() with another ListModel dataModel(). Notice that this requires other changes too (which can be found at the link provided)

提交回复
热议问题