【发布时间】:2014-02-03 19:53:37
【问题描述】:
我有一个水平列表视图,如图
现在当我滚动它时,列表视图会被过度滚动,如下图所示
我真正需要的是即使拖得更多,最后一个元素应该留在最后,如下图
我该怎么做。
编辑
列表视图源
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)
}
}
}
【问题讨论】:
-
可以提供demo应用吗?
-
我已经更新了我的问题
-
您确定您的按钮是来自 QtQuick.Controls 的按钮吗?最后一个没有 label 和 labelSize 属性.....
-
它不在 QtQuick.Controls 中,它是一个自定义按钮。但我认为“按钮”并不是这种行为背后的原因。
-
我面临着完全相同的问题。你找到解决办法了吗?