qml实现循环list

背景:如果需要qml显示循环list,一般是用3个ListView循环交替,实现伪循环,期间逻辑复杂,容易出错,PathView本身自带循环,所以考虑用PathView实现循环

设计:PathView显示5条数据,按照垂直List一个个排好顺序,由于收尾移动时候会空白穿帮,所以用clip控制显示中间三条数据

滚动控制:currentIndex,decrementCurrentIndex(),incrementCurrentIndex()

代码:

Item{
        id: item1
        property int myIndex: 0
        property int onePageCount: 3
        property real oneHeight: 72
        property real oneWidth: 580
        property int isCurrentListView: 1   //0,1,2
        property bool isAdd: true       //direction,down=true,up=false
        property int hightlightIndex: 0

        property int currentIndexPathView: 0    //use this

        Item{
            id: itemClip
            width: item1.oneWidth
            height: item1.oneHeight*3
            clip: true

            PathView {
                id: listView1
                width: item1.oneWidth
                model: listModelSpeedWarning
                delegate: delegeteLine
                pathItemCount: item1.onePageCount+2
                interactive: false

                path: Path {
                    startX: item1.oneWidth/2
                    startY: -item1.oneHeight/2
                    PathQuad { x: item1.oneWidth/2; y: item1.oneHeight*0+item1.oneHeight/2; controlX: item1.oneWidth/2; controlY: item1.oneHeight*0+item1.oneHeight/2 }
                    PathQuad { x: item1.oneWidth/2; y: item1.oneHeight*1+item1.oneHeight/2; controlX: item1.oneWidth/2; controlY: item1.oneHeight*1+item1.oneHeight/2 }
                    PathQuad { x: item1.oneWidth/2; y: item1.oneHeight*2+item1.oneHeight/2; controlX: item1.oneWidth/2; controlY: item1.oneHeight*2+item1.oneHeight/2 }
                    PathQuad { x: item1.oneWidth/2; y: item1.oneHeight*3+item1.oneHeight/2; controlX: item1.oneWidth/2; controlY: item1.oneHeight*3+item1.oneHeight/2 }
                    PathQuad { x: item1.oneWidth/2; y: item1.oneHeight*4+item1.oneHeight/2; controlX: item1.oneWidth/2; controlY: item1.oneHeight*4+item1.oneHeight/2 }
                }

                Component.onCompleted: {
                    listView1.currentIndex = -1
                }
            }

        }

}

问题:windows下测试,按住按键不松手,list滚动会卡住,松手后恢复正常,看来list不能滚动太快

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值