Positioner QML Type
提供了一些关联属性,其中包含项目在定位器中所在位置的详细信息。更多内容...
| Import Statement: | import QtQuick |
附加属性
- index : int
- isFirstItem : bool
- isLastItem : bool
详细说明
Positioner 类型的对象附加在 Column、Row、Flow 或 Grid 中的顶级子项上。它提供了一系列属性,使子项能够确定自己在父级 Column、Row、Flow 或 Grid 布局中的位置。
例如,下图展示了一个包含 16 个子矩形的Grid ,该 是通过Repeater 创建的。每个Rectangle 都使用Positioner.index 显示其在Grid中的索引,并且通过考虑Positioner.isFirstItem ,将第一个项设置为不同的颜色:
Grid {
Repeater {
model: 16
Rectangle {
id: rect
width: 30; height: 30
border.width: 1
color: Positioner.isFirstItem ? "yellow" : "lightsteelblue"
Text { text: rect.Positioner.index }
}
}
}
附加属性文档
Positioner.index : int [read-only attached]
此属性允许该项目确定其在定位器中的索引。
Positioner.isFirstItem : bool [read-only attached]
Positioner.isLastItem : bool [read-only attached]
这些属性分别用于让该项判断自身是否为定位器中的第一个或最后一个项。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.