QML PathView 效果

本文介绍了一个使用ListModel和PathView创建的动态水果视图展示案例,其中包括蓝莓、金橘和葡萄等元素,并通过图片和文字详细展示了每种水果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ListModel {
    id: model
    ListElement { fruit: "Bilberry"; 
                  picture: "http://upload.wikimedia.org/wikipedia/commons/9/91/Norwegian_blueberries.jpg" }
    ListElement { fruit: "Kumquat"; 
                  picture: "http://upload.wikimedia.org/wikipedia/commons/8/82/Kumquat.jpeg" }
    ListElement { fruit: "Grapefruit"; picture: 
                  "http://upload.wikimedia.org/wikipedia/commons/thumb/b/bb/
Table_grapes_on_white.jpg/250px-Table_grapes_on_white.jpg" }
}
Component {
    id: delegate
    Item {
        width: 100; height: 100
        scale: PathView.scale
        Column { Image { anchors.fill: parent; source: picture;  } 
                 Text { text: fruit; font.pointSize: 24; }
        }
    }
}
PathView {
    anchors.fill: parent
    model: model;
    delegate: delegate
    path: Path {
        startX: 100; startY: 100
        PathAttribute { name: "scale"; value: 0.5 }
        PathLine { x:200; y:200 }
        PathAttribute { name: "scale"; value: 1.0 }
        PathLine { x:300; y:100 }
        PathLine { x:100; y:100 }
    }
}

原文链接
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值