Simple Anchor Layout Example¶
Demonstrates anchor layout on a graphics view scene
main.cpp Example File¶
simpleanchorlayout.pro Example File¶
Demonstrates anchor layout on a graphics view scene.
The Simple Anchor Layout example shows the basic use of the QGraphicsAnchorLayout class.
The example starts by creating a QGraphicsScene (
scene
), 3 widgets (a
,b
, andc
), and a QGraphicsAnchorlayout (layout
).First it anchors the top left corner of item
a
to the top left corner oflayout
. This can be done in two steps:Or in one step:
Then the right anchor of
a
is anchored to the left anchor ofb
, and the top of itemb
is anchored to the bottom ofa
.Place a third widget
c
under widgetb
:Items
b
andc
are anchored to each other horizontally:Item c is anchored to the bottom right point of
layout
Finally, QGraphicsWidget
w
is displayed in QGraphicsViewview
.See also
Anchor Layout Example