Stefan Monov
Stefan Monov

Reputation: 11732

QtQuick anchoring syntax confusion

As we know, anchoring is done like this:

anchors.left: rect1.right

... where rect1 is an object deriving from Item.

But the Item QML type doesn't have a right property. So how does this anchoring syntax work?

Upvotes: 0

Views: 61

Answers (2)

S.M.Mousavi
S.M.Mousavi

Reputation: 5246

See this and then this header file. anchors.left for example is a read-only property of type QQuickAnchorLine.
See this and this headers. There is where you can see how it works.

Upvotes: 0

Mitch
Mitch

Reputation: 24416

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, which says:

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.

I'm not entirely certain why they're not documented like regular properties, though.

Upvotes: 3

Related Questions