Skip to content

Instantly share code, notes, and snippets.

@oKcerG
Last active October 19, 2016 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oKcerG/b112802534f022b39db01b56d614533f to your computer and use it in GitHub Desktop.
Save oKcerG/b112802534f022b39db01b56d614533f to your computer and use it in GitHub Desktop.
import QtQuick 2.0
Item {
id: root
height: 0
default property alias data: contentItem.data
property ListView _listView: parent.parent
property Item _adjacentItem: { _listView.contentY; return _listView.itemAt(0, y); }
property bool _adjacentItemIsLastOfSection: _adjacentItem ? _adjacentItem.ListView.section !== _adjacentItem.ListView.nextSection && _adjacentItem !== _listView.contentItem.children[0] : false
Item {
id: contentItem
y: _adjacentItemIsLastOfSection ? Math.min(_adjacentItem.y - _listView.contentY, 0) : 0
}
}
ListView {
anchors.fill: parent
model: yourModel
section {
property: "yourRole"
criteria: ViewSection.FirstCharacter
labelPositioning: ViewSection.CurrentLabelAtStart | ViewSection.InlineLabels
delegate: AdjacentSection {
Text {
padding: 20
text: section
}
}
}
delegate: Text {
text: model.yourRole
leftPadding: 60
padding: 20
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment