QML listview Overscrolls

Roh*_*kar 2 qt listview qml

我有一个图像中给出的水平列表视图初始状态

现在,当我滚动它时,listview被过度滚动,如下图所示 overscoll

我真正需要的是即使拖动更多,最后一个元素应保持在最后,如下图所示正确滚动

我怎样才能做到这一点.

编辑

ListView来源

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)
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

hal*_*7df 5

您需要ListView通过设置其boundsBehavior属性来告诉停止对象边界:

boundsBehavior: Flickable.StopAtBounds

默认情况下,继承的对象会Flickable超出边界并向后移动.

请参阅Qt网站上的boundsBehavior房产描述.