Alexander Dyagilev
Alexander Dyagilev

Reputation: 1425

QML ScrollBar: what is the purpose of stepSize property?

stepSize property

I've tried to initialize this property with different values, but got no visible effect when I scroll my ListView control.

Upvotes: 0

Views: 51

Answers (1)

Stephen Quan
Stephen Quan

Reputation: 26214

In the following ListView, I created 100 records with model: 100 and you will see that stepSize: 0.25 causes the ListView to stop at 0, 25, 50, 75 and 99 spots respectively. It requires snapMode: ScrollBar.SnapOnRelease to be set

    ListView {
        width: 150
        height: 300
        model: 100
        delegate: Frame { ItemDelegate { text: modelData } }
        ScrollBar.vertical: ScrollBar {
            id: vbar
            width: 20
            policy: ScrollBar.AlwaysOn
            snapMode: ScrollBar.SnapOnRelease
            stepSize: 0.25
        }
        WheelHandler {
            onWheel: Qt.callLater(event.angleDelta.y > 0 ? vbar.decrease : vbar.increase)
        }
    }

You can Try it online!

Upvotes: 1

Related Questions