【发布时间】:2019-05-24 10:19:12
【问题描述】:
在我的代码中,我有一个包含 16 个元素的 ListView,我希望当我滚动 listview 时,第一个元素必须始终可见。我该怎么做?
ApplicationWindow {
id: window
visible: true
width: 640
height: 480
ListView {
id:listview
anchors.fill: parent
model: 16
verticalLayoutDirection: ListView.BottomToTop
delegate: Rectangle {
height: listview.height/5
width: listview.width
color: Qt.rgba(Math.random(),Math.random(),Math.random(),1)
Text {
text: index
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "white"
font.pixelSize: 35
}
}
}
}
【问题讨论】: