Qt 프로그래밍/Basic Qt

[Qt 프로그래밍] QML 상대 위치지정 속성 Positioning with Anchors

kwoss2341 2021. 2. 22. 22:06

doc.qt.io/qt-5/qtquick-positioning-anchors.html

 

Positioning with Anchors | Qt Quick 5.15.2

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

doc.qt.io

 

 

 

anchors.left: rect1.right;

Rectangle { id: rect1; ... }
Rectangle { id: rect2; 

anchors.left: rect1.right;

... }

anchors.left: rect1.right

;rect1을 이용하여 rect2 위치를 지정할 수 있다.

 

 

 

 

 

 

 

anchors.left 뿐만아니라 그림처럼 다양한 상대적 위치를 설정할 수 있다.

// 상대적 위치를 지정하기 위해 id를 부여하여 이용하자