I'm developing an application. I need to add data to TreeView but I have some problems with TreeView's nested model.
I created a List Model which is
ListModel {
id: fruitModel
ListElement {
name: "Apple"
price: 2.45
}
}
I am able to show this item by the way of
TreeView {
id: mytreeView
anchors.fill: parent
model: fruitModel
TableViewColumn {
title: "Name"
role: "name"
width: 200
}
TableViewColumn {
title: "Price"
role: "price"
width: 200
}
}
However , I need to show nested items like
ListModel {
ListElement {
categoryName: "Fruits"
collapsed: true
subItems: [
ListElement { itemName: "Orange" , itemPrice: 2.40},
ListElement { itemName: "Apple" , itemPrice: 2.40},
ListElement { itemName: "Pear" , itemPrice: 2.40},
ListElement { itemName: "Lemon" , itemPrice: 2.40}
]
}
}
I listed these items in ListView but I need to list these items in TreeView. So, how can I list this nested ListModel in TreeView using QML?