qml listview实现循环
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
想要什么样的效果,详细一点!!
ListView 不可以做 首尾相接的循环, 首尾相接的循环 要用PathView
Item{
width: 100
height: 300
ListView{
id: __list
anchors.fill: parent
clip: true
model:ListModel{
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
}
delegate: Rectangle{
width: ListView.view.width
height:50
border.width: 1
border.color:"black"
color:"blue"
Text{
anchors.centerIn: parent
text: index
}
}
onAtYEndChanged: {
if(atYEnd && contentY > 0){
timer.start()
}
}
Rectangle {
id: scrollbar
anchors.right: __list.right
y: __list.visibleArea.yPosition * __list.height
width: 10
height: __list.visibleArea.heightRatio * __list.height
color: "black"
}
}
Timer {
id: timer
interval: 500; running: false; repeat: false
onTriggered: {__list.model.append([{"name":"ele"},{"name":"ele"},{"name":"ele"},{"name":"ele"},{"name":"ele"},{"name":"ele"}])}
}
}
ListView 不可以做 首尾相接的循环, 首尾相接的循环 要用PathView
Item{
width: 100
height: 300
ListView{
id: __list
anchors.fill: parent
clip: true
model:ListModel{
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
ListElement { name: "ele"}
}
delegate: Rectangle{
width: ListView.view.width
height:50
border.width: 1
border.color:"black"
color:"blue"
Text{
anchors.centerIn: parent
text: index
}
}
onAtYEndChanged: {
if(atYEnd && contentY > 0){
timer.start()
}
}
Rectangle {
id: scrollbar
anchors.right: __list.right
y: __list.visibleArea.yPosition * __list.height
width: 10
height: __list.visibleArea.heightRatio * __list.height
color: "black"
}
}
Timer {
id: timer
interval: 500; running: false; repeat: false
onTriggered: {__list.model.append([{"name":"ele"},{"name":"ele"},{"name":"ele"},{"name":"ele"},{"name":"ele"},{"name":"ele"}])}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询