I have a QML ListView with a model coming from the C++ side. So far everything looks fine. Now the list items have a section headline property and I want to group the items according to their sections. The section delegate UI element should surrond all items belonging to that section. I can't seem to get around having the section element appear as another list item.
Again, instead of
--------- ------ ------ --------- ------ ------
|section| |item| |item| |section| |item| |item|
--------- ------ ------ --------- ------ ------
I want this
------------------------ ------------------------
| ------ ------ | | ------ ------ |
|section |item| |item| | |section |item| |item| |
| ------ ------ | | ------ ------ |
------------------------ ------------------------
This is basically the code I'm working with so far:
ListView {
width: styles.thumbnailListWidth
height: styles.thumbnailListHeight
orientation: ListView.Horizontal
model: handler.stepList // stepList is generated in C++ code
delegate: Column {
Rectangle {
id: thumbnailContainer
width: 196
height: styles.thumbnailHeight
z: 100
Image {
id: screenshot
anchors.fill: parent
source: "image://steps/screenshot_" + index
}
}
}
section.property: "sectionHeadline"
section.criteria: ViewSection.FullString
section.delegate: Rectangle {
id: sectionContainer
anchors.left: thumbnailContainer.left
width: 300
height: 50
z: 0
Text {
text: section
color: colors.darkCharcoal05
font.family: fonts.montserratBold.name
font.pixelSize: 20
}
}
}
I thought the alignment and the z order might bring the section delegate element behind the list item element, but it doesn't. Any ideas on how to go about this?