PathView类似于ListView,需要model和delegate,但是它的显示方式是沿着我们规定的path(路径)显示.先看一个例子
import Qt 4.7
Rectangle {
width: 500; height: 300;
ListModel {
id: msnModel
ListElement {
name: "01"
pic: "images/Messenger_01.png"
}
ListElement {
name: "02"
pic: "images/Messenger_02.png"
}
ListElement {
name: "03"
pic: "images/Messenger_03.png"
}
ListElement {
name: "04"
pic: "images/Messenger_04.png"
}
}
Component {
id: msnDelegate
Column {
Image{ source: pic; anchors.horizontalCenter: name.horizontalCenter; width: 64; height: 64}
Text { text: name; font.pointSize: 16; color: GridView.isCurrentItem ? "red" :"gray"}
}
}
PathView {
anchors.fill: parent
model: msnModel
delegate: msnDelegate
path: Path {
startX: 120; startY: 100
PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }
PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 }
}
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
}
}
下面来讲讲Path: Path由一个或多个如Pathine,PathQuad,PathCubic等路径段组成。主要应用在PathView中.
PathAttribute能够在Path上某个位置设置一个属性.
PathPercent
PathLine 定义一条直线
PathQuad定义二次贝塞尔曲线
PathcuBic定义三次贝塞尔曲线