2
votes

I have a horizontal listview as given in the imageinitial state

Now when I scroll it the listview gets overscrolled as in the below image overscoll

What I actually need is even if the drag is more , the last element should stay at the end as in the below imagecorrect scroll

How can I do that.

EDIT

ListView Source

ListView{

        id: list
        width: 500
        height: 100
        clip: true
        //anchors.bottom: parent.bottom
        //anchors.bottomMargin: 10
        snapMode: ListView.SnapToItem
        anchors.centerIn: parent
        highlightRangeMode: ListView.StrictlyEnforceRange
        highlightFollowsCurrentItem: true
        highlight: Rectangle { color: "#00000000" ;border.color: "red" ; radius: 5 }
        anchors.horizontalCenter: parent.horizontalCenter
        orientation: ListView.Horizontal
        model: ListModel{
            id: listModel
            ListElement{ name: "File"}
            ListElement{ name: "Edit"}
            ListElement{ name: "Build"}
            ListElement{ name: "Debug"}
            ListElement{ name: "Analyze"}
            ListElement{ name: "Tools"}
            ListElement{ name: "Window"}
            ListElement{ name: "Help"}
        }

        delegate: Button{
            borderColor: buttonBorderColor;buttonColor: buttonFillColor
            width: 100;height: 100 ;labelSize: 18
            label: model.name
            onButtonClick: {
                list.currentIndex = model.index;
                console.log("ListView Button clicked" + model.index)
            }
        }
    }
1
Can you provide demo application?Kakadu
I have updated my questionRohit Walavalkar
Are you sure that your Button is Button from QtQuick.Controls? Last one doesn't have label and labelSize properties.....Kakadu
Its not in QtQuick.Controls its a custo button. But I think that the "Button" is not the reason behind this behavior.Rohit Walavalkar
I am facing the exact same problem. Have you found the solution for it?Aozi

1 Answers

5
votes

You need to tell the ListView to stop at the object bounds by setting its boundsBehavior property:

boundsBehavior: Flickable.StopAtBounds

By default, objects that inherit Flickable overshoot the bounds and move back.

See the boundsBehavior property description on the Qt website.