ListView with sections and ObjectModel
-
@FOXLISIN Check this link
http://doc.qt.io/qt-5/qml-qtquick-listview.html -
I have read this article. And i know how to use sections with ListModel, for example. But i dont know how to do it with ObjectModel:
ListView { width: 500 height: 1000 model: ObjectModel { Rectangle {property string type: "first"; width: 500; height: 50} Rectangle {property string type: "first"; width: 500; height: 50} Rectangle {property string type: "second"; width: 500; height: 50} Rectangle {property string type: "second"; width: 500; height: 50} } section { section.property: ?????? //<-- should i write "type" here or what? criteria: ViewSection.FullString labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart } }
-
@FOXLISIN : The below link explains how to use object models.
http://doc.qt.io/qt-5/qml-qtqml-models-objectmodel.html
Create object model separately for easy maintainability. -
@FOXLISIN When an ObjectModel is used in a view, the view does not require a delegate since the ObjectModel already contains the visual delegate hence unable to get the property for creating the sections.
I have tried in code but unable to create the sections.
However it is easy to do while having list model with delegates.
http://doc.qt.io/qt-5/qml-qtquick-listview.html#section-prop