Last active
October 19, 2016 14:41
-
-
Save oKcerG/b112802534f022b39db01b56d614533f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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