repeater的使用

Repeater控件在delegate中要求最外层有一个单独的控件进行重复创建。如果直接使用img和text,Repeater将无法正常工作,因为它需要一个容器来包裹这些元素并进行重复实例化。
摘要由CSDN通过智能技术生成
ListModel{
        id: myFlowListModel
    }
    Component{
        id: myDelegate
        Rectangle{
            width: 92
            height: 60
            color: "transparent"
            Image {
                id: qwname
                source: myImg
                width: 92
                height: 53
            }
            Text {
                id: helloText
                text: myString
                font.pixelSize: 12
            }
        }
    }
    ScrollView{
        anchors.top: parent.top
        anchors.topMargin: 30
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        clip: true
        ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
        Flow{
            id: myFlow
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.top: parent.top
            width: outSideRec.width - 40
            height: parent.height
            spacing: 10
            visible: true
            Repeater{
                model: myFlowListModel
                delegate: myDelegate
            }
        }

repeater的delegate中最外层只能有一个控件,然后repeater会重复创建这个控件,但是如果没有最外层的rectangle包裹,就同时需要重复创建img和text,repeater无法创建

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值