QtQuick锚定语法混乱

QtQuick anchoring syntax confusion

正如我们know,锚定是这样完成的:

anchors.left: rect1.right

... 其中 rect1 是从 Item.

派生的对象

但是 Item QML 类型没有 right 属性。那么这种锚定语法是如何工作的呢?

But the Item QML type doesn't have a right property

It does. The documentation for e.g. anchors.right links to Positioning with Anchors,表示:

In addition to the more traditional Grid, Row, and Column, Qt Quick also provides a way to layout items using the concept of anchors. Each item can be thought of as having a set of 7 invisible "anchor lines": left, horizontalCenter, right, top, verticalCenter, baseline, and bottom.

不过,我不完全确定为什么没有像常规属性那样记录它们。

参见 this and then this header 文件。 anchors.left 例如 read-only 属性 类型 QQuickAnchorLine.
this and this headers。在那里你可以看到它是如何工作的。