上一话题

Pad Navigator Example

下一话题

天气锚点布局范例

简单锚点布局范例

演示图形视图场景中的锚点布局。

The Simple Anchor Layout example shows the basic use of the QGraphicsAnchorLayout 类。

../_images/graphicssimpleanchorlayout-example.png

The example starts by creating a QGraphicsScene ( scene ), 3 widgets ( a , b ,和 c ), and a QGraphicsAnchorlayout ( layout ).

First it anchors the top left corner of item a to the top left corner of layout . This can be done in two steps:

Or in one step:

Then the right anchor of a is anchored to the left anchor of b , and the top of item b is anchored to the bottom of a .

Place a third widget c under widget b :

Items b and c are anchored to each other horizontally:

Item c is anchored to the bottom right point of layout

最后, QGraphicsWidget w is displayed in QGraphicsView view .

范例工程 @ code.qt.io