Limit QML PathView to 1 index scroll

I created a kind of page switcher using the pathview element, which works fine, but if you click enough, it iterates over several pages. I want to know if there is a way to limit my pathview element so that I can only change one index at a time?

Edit: I do not want to know how I can create my own switch element, I already have a path that works smoothly with the pages behind my finger, etc. All I want to know is how I can limit the pathview to changing only one index at a time.

+3
source share
2 answers

Qt 5 seems to have this functionality, so I will just leave it that way for now.

+1
source

You can try using MouseAreaand incrementCurrentIndex/decrementCurrentIndex

Rectangle {
    // ...
    PathView {
        id: path_view
        anchors.fill: parent
        interactive: false
        // model, delegate, etc...
        MouseArea {
            anchors.fill: parent
            property int x_pos
            onPressed: {
                x_pos = mouse.x
            }
            onReleased: {
                if (x_pos > mouse.x) {
                    path_view.incrementCurrentIndex()
                }
                else {
                    path_view.decrementCurrentIndex()
                }
            }
        }
    }
}
+2
source

All Articles