import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQml.Models 2.3
ListView {
id: view
anchors.fill: parent
focus: true
highlight: Rectangle {
width: view.width; height: view.currentItem.height
y: view.currentItem.y
color: "blue"
}
highlightFollowsCurrentItem: true
model: DelegateModel {
model: catalogTreeModel //common QAbstractItemModel model
delegate: Item {
width: view.width; height: colDlg.height
Column {
id: colDlg
width: view.width
height: itemDlg.height + subView.height
Item {
id: itemDlg
width: view.width
height: childrenRect.height
Text { text: session }
MouseArea {
anchors.fill: parent
propagateComposedEvents: true
onClicked: {
view.currentIndex = index
subView.shown = !subView.shown
} //onClicked:
} //MouseArea
} //Item
ListView { // nested ListView
id: subView
property int parentIndex: index
property bool isParrentSelected: view.currentIndex===index
property bool shown: false
width: view.width; height: shown ? /*_rowsCount * 25*/ subView.count * 25 : 0
visible: shown
enabled: shown
highlight: Rectangle {
id: subHighlight
visible: subView.isParrentSelected
focus: true
color: "red"
} //highlight:
model: DelegateModel {
model: catalogTreeModel
rootIndex: view.model.modelIndex(subView.parentIndex) // change root index for nested branch
delegate: Item {
width: view.width; height: txt.contentHeight
Text { id: txt; text: session }
MouseArea {
anchors.fill: parent
z: 1
hoverEnabled: true
propagateComposedEvents: true
onClicked: {
subView.currentIndex = index
view.currentIndex = subView.parentIndex
} //onClicked:
} //MouseArea
} //delegate:
} //model
} //ListView
} //Column
} //delegate:
} //model:
} //ListView
Additional info here.