【发布时间】:2016-08-12 08:29:24
【问题描述】:
我创建了一个矩形来包裹水平列表视图,但它显示在其边界之上。问题如下图: 在此图像中,列表视图显示当前显示项目的前面和下面的项目。当时如何只显示当前项目,当用户滑动列表视图时,项目更改一项?
我的源代码在这里:
ApplicationWindow {
visible: true
width: 900
height: 480
title: qsTr("Hello World")
Rectangle{
id: bound
anchors.fill: parent
color: "blue"
}
Rectangle{
id: listview
width: 300
height: 300
anchors.centerIn: parent
color: "red"
ListView{
id:lst
width: 250
height: 250
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
//preferredHighlightBegin: 0
//preferredHighlightEnd: 200
highlightRangeMode: ListView.StrictlyEnforceRange
boundsBehavior: Flickable.StopAtBounds
highlightFollowsCurrentItem: true
keyNavigationWraps: true
interactive: true
model: 10
delegate: Rectangle{
id: dele
width: 250
height: 250
anchors.centerIn: listview
color: Qt.rgba(Math.random(),Math.random(),Math.random(),1)
}
}
}
}
【问题讨论】:
标签: qt listview delegates qml qtquick2