文件:590m.com/f/–c69e08(访问密码:)
以下内容无关:
——————————————-分割线———————————————
pathView的使用类似与ListView,都需要模型(model)和代理(delegate),只不过pathView多了一个路径(path)属性,顾名思义路径就是item滑动的路径.
一个Path可以由下面多个Path段组成(之前讲解PathAnimation时提过):
其中PathAttribute用来给路径上定义带有值的命名属性。而PathPercent则用来对每个间距进行一个调整。
3.PathView实战
我们参考韦东山之前发布的一个Qt开源视频,如下图所示:
最终做出来如下图所示:
效果图如下所示(有点大,需要多等下刷新出来):
源码已经上传到群里,由于我们借用了别人的UI图,所以请不要将别人的UI图片用在商业上,仅供学习参考使用!!!
核心代码如下所示:
ListElement { name: "多媒体" back: "qrc:/images/media_nor.png" } ListElement { name: "系统设置" back: "qrc:/images/system_nor.png" } ListElement { name: "智能家电" back: "qrc:/images/machine_nor.png" } ListElement { name: "卫生医疗" back: "qrc:/images/medical_nor.png" } ListElement { name: "公共服务" back: "qrc:/images/public_nor.png" } } Component { id: delegate App { id: rect width: itemSize.width height: itemSize.height z: PathView.iconZ scale: PathView.iconScale imagSrc: back label: name enabled: view.opacity == 1.0 transform: Rotation{ origin.x: rect.width/2.0 origin.y: rect.height/2.0 axis{x:0;y:1;z:0} angle: rect.PathView.iconAngle } MouseArea { anchors.fill: parent onClicked: { if (view.currentIndex == index) newJumpWindow("qrc:/AppWindow.qml", name) } } } } PathView { id: view anchors.centerIn: parent width: (itemCount-1.9)*itemSize.width height: wind.height model: mymodel delegate: delegate flickDeceleration: 300 preferredHighlightBegin: 0.5 preferredHighlightEnd: 0.5 pathItemCount: itemCount clip: true enabled: opacity == 1.0 path: Path { id: path startX: 0 startY: view.height * 0.45 PathAttribute{name:"iconZ";value: 0} PathAttribute{name:"iconAngle";value: -50} PathAttribute{name:"iconScale";value: 0.7} PathLine{x:view.width/2; y: path.startY} // 设置初始Z为0,角度为70 大小比例为0.6 PathAttribute{name:"iconZ";value: 100} PathAttribute{name:"iconAngle";value: 0} PathAttribute{name:"iconScale";value: 1.0} PathLine{x:view.width; y: path.startY} PathAttribute{name:"iconZ";value: 0} PathAttribute{name:"iconAngle";value: 50} PathAttribute{name:"iconScale";value: 0.7} } }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232263.html原文链接:https://javaforall.net
