1.Row布局
- Row中的item可以不需要使用anchors布局,就能通过行的形式进行布局。
- 并且item可以使用Positioner附加属性来访问有关其在Row中的位置及其他信息.
示例如下所示,通过Positioner获取每个元素位置标签:
Window {
width: 320;
height: 240;
visible: true;
Row {
anchors.centerIn: parent
spacing: 4
Repeater {
model: 4
Rectangle {
id: rect
width: 30; height: 30
border.width: 1
Text {
text: rect.Positioner.index
}
color: {
if (Positioner.isFirstItem) {
return "red"
} else if (Positioner.isLastItem) {
return "yellow"
} else {
return "lightsteelblue"