锚属性
Anchor properties
在 Qt 中,您可以使用 element.left
或 element.right
等表达式来引用元素的锚线,其中 element
以某种方式引用父元素或同级元素。例如:
Item {
Text {
text: "at right edge of parent"
anchors.right: parent.right
}
}
会将 Text
元素锚定到其父元素的右边缘,在本例中是 Item
元素。
但是,当浏览 Item
的 documentation 时,没有提到 left
或 right
属性(只有 anchors.left
和 anchors.right
)。这部分文档包括所有继承的成员,因此应该列出它。
这些属性只是未记录还是以某种方式特殊引用?
根据代码中的documentation, they refer specific imaginary lines that goes through and around the Item
. They are surely properties, as you can see here。
但是它们是保密的,可能是为了不打乱锚定。他们的计算可以找到here,其背后的原理应该很清楚。因此,当您指的是 parent.right
时,您指的是 parent
的 x + width
。
在 Qt 中,您可以使用 element.left
或 element.right
等表达式来引用元素的锚线,其中 element
以某种方式引用父元素或同级元素。例如:
Item {
Text {
text: "at right edge of parent"
anchors.right: parent.right
}
}
会将 Text
元素锚定到其父元素的右边缘,在本例中是 Item
元素。
但是,当浏览 Item
的 documentation 时,没有提到 left
或 right
属性(只有 anchors.left
和 anchors.right
)。这部分文档包括所有继承的成员,因此应该列出它。
这些属性只是未记录还是以某种方式特殊引用?
根据代码中的documentation, they refer specific imaginary lines that goes through and around the Item
. They are surely properties, as you can see here。
但是它们是保密的,可能是为了不打乱锚定。他们的计算可以找到here,其背后的原理应该很清楚。因此,当您指的是 parent.right
时,您指的是 parent
的 x + width
。