对于我在表格中显示数据的项目,最新的数据是最相关的,所以我希望它是最明显的,但也应该可以看到较早的数据。以下代码包含带有滚动条的视图。
ScrollView{
id:dataScrollView
width: parent.width
anchors.top: headerWrapper.bottom
height:parent.height - headerWrapper.height
ScrollBar.vertical.policy: ScrollBar.AlwaysOn;
clip: true
TableView{
id: table
columnSpacing: 1
rowSpacing: 1
clip: true
implicitHeight: column.height - 33
implicitWidth: column.width
model: modelItem
delegate: compColored
onContentHeightChanged: {
//new data has come in I want to scroll to the bottom
console.log("update scroll to bottom" )
}
}
}
我确切地知道将代码放在哪里,但我不知道如何使滚动条到达底部或如何设置滚动条的位置。有人可以指出我如何设置滚动条的位置吗?
作为TableView
继承Flickable
,您可以简单地通过以下方式在视口中重新定位 contentItem:
onContentHeightChanged: {
table.contentY = table.contentHeight - table.height
}
并且 Flickable 的 contentItem 底部区域将在视口中可见。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句