Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import QtQuick.Controls 2.0
import QtQuick 2.7
import QtQml 2.2
ScrollBar {
id: scrollBar
property ListView listView: parent
stepSize: 1 / listView.count
property real effectiveStep: stepSize * (1 - 0)
size: listView.visibleArea.heightRatio
active: listView.moving || pressed
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
}
Binding on position {
when: !scrollBar.pressed
value: listView.visibleArea.yPosition
}
Binding {
when: scrollBar.pressed
target: listView
property: "contentY"
value: scrollBar.stepSize ? Math.round(scrollBar.position/effectiveStep) * scrollBar.effectiveStep * listView.contentHeight : scrollBar.position * listView.contentHeight
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment