Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtGui.QGraphicsAnchorLayout Class Reference

The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics View. More...

Inheritance diagram for QtGui.QGraphicsAnchorLayout:
Collaboration diagram for QtGui.QGraphicsAnchorLayout:

Public Member Functions

 QGraphicsAnchorLayout (IQGraphicsLayoutItem parent=null)
 
 
override void CreateProxy ()
 
new QGraphicsAnchor AddAnchor (IQGraphicsLayoutItem firstItem, Qt.AnchorPoint firstEdge, IQGraphicsLayoutItem secondItem, Qt.AnchorPoint secondEdge)
 
 
new void AddAnchors (IQGraphicsLayoutItem firstItem, IQGraphicsLayoutItem secondItem, Qt.Orientation orientations=Qt.Orientation.Horizontal|Qt.Orientation.Vertical)
 
 
new void AddCornerAnchors (IQGraphicsLayoutItem firstItem, Qt.Corner firstCorner, IQGraphicsLayoutItem secondItem, Qt.Corner secondCorner)
 
 
new QGraphicsAnchor Anchor (IQGraphicsLayoutItem firstItem, Qt.AnchorPoint firstEdge, IQGraphicsLayoutItem secondItem, Qt.AnchorPoint secondEdge)
 
 
override int Count ()
 
 
override void Invalidate ()
 
 
override IQGraphicsLayoutItem ItemAt (int index)
 
 
override void RemoveAt (int index)
 
 
new void SetSpacing (double spacing)
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtGui.QGraphicsLayout
 QGraphicsLayout (IQGraphicsLayoutItem parent=null)
 
 
override void CreateProxy ()
 
new void Activate ()
 
 
override void GetContentsMargins (ref double left, ref double top, ref double right, ref double bottom)
 
 
new bool IsActivated ()
 
 
new void SetContentsMargins (double left, double top, double right, double bottom)
 
 
override void UpdateGeometry ()
 
 
virtual void OnWidgetEvent (QEvent e)
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtGui.QGraphicsLayoutItem
 QGraphicsLayoutItem (IQGraphicsLayoutItem parent=null, bool isLayout=false)
 
 
new QRectF ContentsRect ()
 
 
new QSizeF EffectiveSizeHint (Qt.SizeHint which)
 
 
new QSizeF EffectiveSizeHint (Qt.SizeHint which, QSizeF constraint)
 
 
new IQGraphicsItem GraphicsItem ()
 
 
new bool IsLayout ()
 
 
new bool OwnedByLayout ()
 
 
new void SetMaximumSize (double w, double h)
 
 
new void SetMinimumSize (double w, double h)
 
 
new void SetPreferredSize (double w, double h)
 
 
new void SetSizePolicy (QSizePolicy.Policy hPolicy, QSizePolicy.Policy vPolicy, QSizePolicy.ControlType controlType=QSizePolicy.ControlType.DefaultType)
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtGui.IQGraphicsLayoutItem
new QRectF ContentsRect ()
 
new QSizeF EffectiveSizeHint (Qt.SizeHint which)
 
new QSizeF EffectiveSizeHint (Qt.SizeHint which, QSizeF constraint)
 
void GetContentsMargins (ref double left, ref double top, ref double right, ref double bottom)
 
new IQGraphicsItem GraphicsItem ()
 
new bool IsLayout ()
 
new bool OwnedByLayout ()
 
new void SetMaximumSize (double w, double h)
 
new void SetMinimumSize (double w, double h)
 
new void SetPreferredSize (double w, double h)
 
new void SetSizePolicy (QSizePolicy.Policy hPolicy, QSizePolicy.Policy vPolicy, QSizePolicy.ControlType controlType=QSizePolicy.ControlType.DefaultType)
 
void UpdateGeometry ()
 

Protected Member Functions

 QGraphicsAnchorLayout (System.Type dummy)
 
new QSizeF SizeHint (Qt.SizeHint which)
 
 
override QSizeF SizeHint (Qt.SizeHint which, QSizeF constraint)
 
 
- Protected Member Functions inherited from QtGui.QGraphicsLayout
 QGraphicsLayout (System.Type dummy)
 
new void AddChildLayoutItem (IQGraphicsLayoutItem layoutItem)
 
 
- Protected Member Functions inherited from QtGui.QGraphicsLayoutItem
 QGraphicsLayoutItem (System.Type dummy)
 
new void SetGraphicsItem (IQGraphicsItem item)
 
 
new void SetOwnedByLayout (bool ownedByLayout)
 
 
new QSizeF SizeHint (Qt.SizeHint which)
 
 

Properties

override QRectF Geometry [get, set]
 
 
new double HorizontalSpacing [get, set]
 
 
new double VerticalSpacing [get, set]
 
 
- Properties inherited from QtGui.QGraphicsLayout
static bool InstantInvalidatePropagation [get, set]
 
 
- Properties inherited from QtGui.QGraphicsLayoutItem
virtual QRectF Geometry [get, set]
 
 
new double MaximumHeight [get, set]
 
 
new QSizeF MaximumSize [get, set]
 
 
new double MaximumWidth [get, set]
 
 
new double MinimumHeight [get, set]
 
 
new QSizeF MinimumSize [get, set]
 
 
new double MinimumWidth [get, set]
 
 
new IQGraphicsLayoutItem ParentLayoutItem [get, set]
 
 
new double PreferredHeight [get, set]
 
 
new QSizeF PreferredSize [get, set]
 
 
new double PreferredWidth [get, set]
 
 
new QSizePolicy SizePolicy [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 
- Properties inherited from QtGui.IQGraphicsLayoutItem
QRectF Geometry [get, set]
 
System.Double MaximumHeight [get, set]
 
QSizeF MaximumSize [get, set]
 
System.Double MaximumWidth [get, set]
 
System.Double MinimumHeight [get, set]
 
QSizeF MinimumSize [get, set]
 
System.Double MinimumWidth [get, set]
 
IQGraphicsLayoutItem ParentLayoutItem [get, set]
 
System.Double PreferredHeight [get, set]
 
QSizeF PreferredSize [get, set]
 
System.Double PreferredWidth [get, set]
 
QSizePolicy SizePolicy [get, set]
 

Additional Inherited Members

- Protected Attributes inherited from QtGui.QGraphicsLayoutItem
SmokeInvocation interceptor
 

Detailed Description

The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics View.

The anchor layout allows developers to specify how widgets should be placed relative to each other, and to the layout itself. The specification is made by adding anchors to the layout by calling addAnchor(), addAnchors() or addCornerAnchors().

Existing anchors in the layout can be accessed with the anchor() function. Items that are anchored are automatically added to the layout, and if items are removed, all their anchors will be automatically removed.

Anchors are always set up between edges of an item, where the "center" is also considered to be an edge. Consider the following example:

layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight);

layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom);

Here, the right edge of item a is anchored to the left edge of item b and the bottom edge of item a is anchored to the top edge of item b, with the result that item b will be placed diagonally to the right and below item b.

The addCornerAnchors() function provides a simpler way of anchoring the corners of two widgets than the two individual calls to addAnchor() shown in the code above. Here, we see how a widget can be anchored to the top-left corner of the enclosing layout:

layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner);

In cases where anchors are used to match the widths or heights of widgets, it is convenient to use the addAnchors() function. As with the other functions for specifying anchors, it can also be used to anchor a widget to a layout.

Size Hints and Size Policies in an Anchor Layout

QGraphicsAnchorLayout respects each item's size hints and size policies. Note that there are some properties of QSizePolicy that are not respected.

Spacing within an Anchor Layout

The layout may distribute some space between the items. If the spacing has not been explicitly specified, the actual amount of space will usually be 0.

However, if the first edge is the opposite of the second edge (e.g., the right edge of the first widget is anchored to the left edge of the second widget), the size of the anchor will be queried from the style through a pixel metric: PM_LayoutHorizontalSpacing for horizontal anchors and PM_LayoutVerticalSpacing for vertical anchors.

If the spacing is negative, the items will overlap to some extent.

Known issues

There are some features that QGraphicsAnchorLayout currently does not support. This might change in the future, so avoid using these features if you want to avoid any future regressions in behaviour:

Stretch factors are not respected.

QSizePolicy::ExpandFlag is not respected.

Height for width is not respected.

See also QGraphicsLinearLayout, QGraphicsGridLayout, and QGraphicsLayout.

Constructor & Destructor Documentation

QtGui.QGraphicsAnchorLayout.QGraphicsAnchorLayout ( System.Type  dummy)
protected
QtGui.QGraphicsAnchorLayout.QGraphicsAnchorLayout ( IQGraphicsLayoutItem  parent = null)

Constructs a QGraphicsAnchorLayout instance. parent is passed to QGraphicsLayout's constructor.

Member Function Documentation

new QGraphicsAnchor QtGui.QGraphicsAnchorLayout.AddAnchor ( IQGraphicsLayoutItem  firstItem,
Qt.AnchorPoint  firstEdge,
IQGraphicsLayoutItem  secondItem,
Qt.AnchorPoint  secondEdge 
)

Creates an anchor between the edge firstEdge of item firstItem and the edge secondEdge of item secondItem. The spacing of the anchor is picked up from the style. Anchors between a layout edge and an item edge will have a size of 0. If there is already an anchor between the edges, the the new anchor will replace the old one.

firstItem and secondItem are automatically added to the layout if they are not part of the layout. This means that count() can increase by up to 2.

The spacing an anchor will get depends on the type of anchor. For instance, anchors from the Right edge of one item to the Left edge of another (or vice versa) will use the default horizontal spacing. The same behaviour applies to Bottom to Top anchors, (but they will use the default vertical spacing). For all other anchor combinations, the spacing will be 0. All anchoring functions will follow this rule.

The spacing can also be set manually by using QGraphicsAnchor::setSpacing() method.

Calling this function where firstItem or secondItem are ancestors of the layout have undefined behaviour.

See also addAnchors() and addCornerAnchors().

new void QtGui.QGraphicsAnchorLayout.AddAnchors ( IQGraphicsLayoutItem  firstItem,
IQGraphicsLayoutItem  secondItem,
Qt.Orientation  orientations = Qt.Orientation.Horizontal|Qt.Orientation.Vertical 
)

Anchors two or four edges of firstItem with the corresponding edges of secondItem, so that firstItem has the same size as secondItem in the dimensions specified by orientations.

For example, the following example anchors the left and right edges of two items to match their widths:

layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft);

layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight);

This can also be achieved using the following line of code:

layout->addAnchors(b, c, Qt::Horizontal);

See also addAnchor() and addCornerAnchors().

new void QtGui.QGraphicsAnchorLayout.AddCornerAnchors ( IQGraphicsLayoutItem  firstItem,
Qt.Corner  firstCorner,
IQGraphicsLayoutItem  secondItem,
Qt.Corner  secondCorner 
)

Creates two anchors between firstItem and secondItem specified by the corners, firstCorner and secondCorner, where one is for the horizontal edge and another one for the vertical edge.

This is a convenience function, since anchoring corners can be expressed as anchoring two edges. For instance:

layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop);

layout->addAnchor(a, Qt::AnchorLeft, layout, Qt::AnchorLeft);

This can also be achieved with the following line of code:

layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner);

If there is already an anchor between the edge pairs, it will be replaced by the anchors that this function specifies.

firstItem and secondItem are automatically added to the layout if they are not part of the layout. This means that count() can increase by up to 2.

See also addAnchor() and addAnchors().

new QGraphicsAnchor QtGui.QGraphicsAnchorLayout.Anchor ( IQGraphicsLayoutItem  firstItem,
Qt.AnchorPoint  firstEdge,
IQGraphicsLayoutItem  secondItem,
Qt.AnchorPoint  secondEdge 
)

Returns the anchor between the anchor points defined by firstItem and firstEdge and secondItem and secondEdge. If there is no such anchor, the function will return 0.

override int QtGui.QGraphicsAnchorLayout.Count ( )
virtual

Reimplemented from QGraphicsLayout::count().

Implements QtGui.QGraphicsLayout.

override void QtGui.QGraphicsAnchorLayout.CreateProxy ( )
virtual

Reimplemented from QtGui.QGraphicsLayoutItem.

new void QtGui.QGraphicsAnchorLayout.Dispose ( )
override void QtGui.QGraphicsAnchorLayout.Invalidate ( )
virtual

Reimplemented from QGraphicsLayout::invalidate().

Reimplemented from QtGui.QGraphicsLayout.

override IQGraphicsLayoutItem QtGui.QGraphicsAnchorLayout.ItemAt ( int  index)
virtual

Reimplemented from QGraphicsLayout::itemAt().

Implements QtGui.QGraphicsLayout.

override void QtGui.QGraphicsAnchorLayout.RemoveAt ( int  index)
virtual

Reimplemented from QGraphicsLayout::removeAt().

Removes the layout item at index without destroying it. Ownership of the item is transferred to the caller.

Removing an item will also remove any of the anchors associated with it.

See also itemAt() and count().

Implements QtGui.QGraphicsLayout.

new void QtGui.QGraphicsAnchorLayout.SetSpacing ( double  spacing)

Sets the default horizontal and the default vertical spacing for the anchor layout to spacing.

If an item is anchored with no spacing associated with the anchor, it will use the default spacing.

QGraphicsAnchorLayout does not support negative spacings. Setting a negative value will unset the previous spacing and make the layout use the spacing provided by the current widget style.

See also setHorizontalSpacing() and setVerticalSpacing().

new QSizeF QtGui.QGraphicsAnchorLayout.SizeHint ( Qt.SizeHint  which)
protected

Reimplemented from QGraphicsLayoutItem::sizeHint().

override QSizeF QtGui.QGraphicsAnchorLayout.SizeHint ( Qt.SizeHint  which,
QSizeF  constraint 
)
protectedvirtual

Reimplemented from QGraphicsLayoutItem::sizeHint().

Implements QtGui.QGraphicsLayoutItem.

Property Documentation

override QRectF QtGui.QGraphicsAnchorLayout.Geometry
getset

Reimplemented from QGraphicsLayoutItem::setGeometry().

new double QtGui.QGraphicsAnchorLayout.HorizontalSpacing
getset

Returns the default horizontal spacing for the anchor layout.

Sets the default horizontal spacing for the anchor layout to spacing.

new double QtGui.QGraphicsAnchorLayout.VerticalSpacing
getset

Returns the default vertical spacing for the anchor layout.

Sets the default vertical spacing for the anchor layout to spacing.