锚属性

Anchor properties

在 Qt 中,您可以使用 element.leftelement.right 等表达式来引用元素的锚线,其中 element 以某种方式引用父元素或同级元素。例如:

Item {
    Text {
        text: "at right edge of parent"
        anchors.right: parent.right
    }
}

会将 Text 元素锚定到其父元素的右边缘,在本例中是 Item 元素。

但是,当浏览 Itemdocumentation 时,没有提到 leftright 属性(只有 anchors.leftanchors.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 时,您指的是 parentx + width