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

The QGraphicsLinearLayout class provides a horizontal or vertical layout for managing widgets in Graphics View. More...

Inheritance diagram for QtGui.QGraphicsLinearLayout:
Collaboration diagram for QtGui.QGraphicsLinearLayout:

Public Member Functions

 QGraphicsLinearLayout (IQGraphicsLayoutItem parent=null)
 
 
 QGraphicsLinearLayout (Qt.Orientation orientation, IQGraphicsLayoutItem parent=null)
 
 
override void CreateProxy ()
 
new void AddItem (IQGraphicsLayoutItem item)
 
 
new void AddStretch (int stretch=1)
 
 
new Qt.AlignmentFlag Alignment (IQGraphicsLayoutItem item)
 
 
override int Count ()
 
 
new void Dump (int indent=0)
 
new void InsertItem (int index, IQGraphicsLayoutItem item)
 
 
new void InsertStretch (int index, int stretch=1)
 
 
override void Invalidate ()
 
 
override IQGraphicsLayoutItem ItemAt (int index)
 
 
new double ItemSpacing (int index)
 
 
override void RemoveAt (int index)
 
 
new void RemoveItem (IQGraphicsLayoutItem item)
 
 
new void SetAlignment (IQGraphicsLayoutItem item, Qt.AlignmentFlag alignment)
 
 
new void SetItemSpacing (int index, double spacing)
 
 
new void SetStretchFactor (IQGraphicsLayoutItem item, int stretch)
 
 
new QSizeF SizeHint (Qt.SizeHint which)
 
 
new int StretchFactor (IQGraphicsLayoutItem item)
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtGui.QGraphicsLayout
 QGraphicsLayout (IQGraphicsLayoutItem parent=null)
 
 
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

 QGraphicsLinearLayout (System.Type dummy)
 
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 Qt.Orientation Orientation [get, set]
 
 
new double Spacing [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 QGraphicsLinearLayout class provides a horizontal or vertical layout for managing widgets in Graphics View.

The default orientation for a linear layout is Qt::Horizontal. You can choose a vertical orientation either by calling setOrientation(), or by passing Qt::Vertical to QGraphicsLinearLayout's constructor.

The most common way to use QGraphicsLinearLayout is to construct an object on the heap with no parent, add widgets and layouts by calling addItem(), and finally assign the layout to a widget by calling QGraphicsWidget::setLayout().

QGraphicsScene scene;

QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);

QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);

QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;

layout->addItem(textEdit);

layout->addItem(pushButton);

QGraphicsWidget *form = new QGraphicsWidget;

form->setLayout(layout);

scene.addItem(form);

You can add widgets, layouts, stretches (addStretch(), insertStretch() or setStretchFactor()), and spacings (setItemSpacing()) to a linear layout. The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle this. You can access each item in the layout by calling count() and itemAt(). Calling removeAt() or removeItem() will remove an item from the layout, without destroying it.

Size Hints and Size Policies in QGraphicsLinearLayout

QGraphicsLinearLayout respects each item's size hints and size policies, and when the layout contains more space than the items can fill, each item is arranged according to the layout's alignment for that item. You can set an alignment for each item by calling setAlignment(), and check the alignment for any item by calling alignment(). By default, items are aligned to the top left.

Spacing within QGraphicsLinearLayout

Between the items, the layout distributes some space. The actual amount of space depends on the managed widget's current style, but the common spacing is 4. You can also set your own spacing by calling setSpacing(), and get the current spacing value by calling spacing(). If you want to configure individual spacing for your items, you can call setItemSpacing().

Stretch Factor in QGraphicsLinearLayout

You can assign a stretch factor to each item to control how much space it will get compared to the other items. By default, two identical widgets arranged in a linear layout will have the same size, but if the first widget has a stretch factor of 1 and the second widget has a stretch factor of 2, the first widget will get 1/3 of the available space, and the second will get 2/3.

QGraphicsLinearLayout calculates the distribution of sizes by adding up the stretch factors of all items, and then dividing the available space accordingly. The default stretch factor is 0 for all items; a factor of 0 means the item does not have any defined stretch factor; effectively this is the same as setting the stretch factor to 1. The stretch factor only applies to the available space in the lengthwise direction of the layout (following its orientation). If you want to control both the item's horizontal and vertical stretch, you can use QGraphicsGridLayout instead.

QGraphicsLinearLayout Compared to Other Layouts

QGraphicsLinearLayout is very similar to QVBoxLayout and QHBoxLayout, but in contrast to these classes, it is used to manage QGraphicsWidget and QGraphicsLayout instead of QWidget and QLayout.

See also QGraphicsGridLayout and QGraphicsWidget.

Constructor & Destructor Documentation

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

Constructs a QGraphicsLinearLayout instance using Qt::Horizontal orientation. parent is passed to QGraphicsLayout's constructor.

QtGui.QGraphicsLinearLayout.QGraphicsLinearLayout ( Qt.Orientation  orientation,
IQGraphicsLayoutItem  parent = null 
)

Constructs a QGraphicsLinearLayout instance. You can pass the orientation for the layout, either horizontal or vertical, and parent is passed to QGraphicsLayout's constructor.

Member Function Documentation

new void QtGui.QGraphicsLinearLayout.AddItem ( IQGraphicsLayoutItem  item)

This convenience function is equivalent to calling insertItem(-1, item).

new void QtGui.QGraphicsLinearLayout.AddStretch ( int  stretch = 1)

This convenience function is equivalent to calling insertStretch(-1, stretch).

new Qt.AlignmentFlag QtGui.QGraphicsLinearLayout.Alignment ( IQGraphicsLayoutItem  item)

Returns the alignment for item. The default alignment is Qt::AlignTop | Qt::AlignLeft.

The alignment decides how the item is positioned within its assigned space in the case where there's more space available in the layout than the widgets can occupy.

See also setAlignment().

override int QtGui.QGraphicsLinearLayout.Count ( )
virtual

Reimplemented from QGraphicsLayout::count().

Implements QtGui.QGraphicsLayout.

override void QtGui.QGraphicsLinearLayout.CreateProxy ( )
virtual

Reimplemented from QtGui.QGraphicsLayout.

new void QtGui.QGraphicsLinearLayout.Dispose ( )
new void QtGui.QGraphicsLinearLayout.Dump ( int  indent = 0)
new void QtGui.QGraphicsLinearLayout.InsertItem ( int  index,
IQGraphicsLayoutItem  item 
)

Inserts item into the layout at index, or before any item that is currently at index.

See also addItem(), itemAt(), insertStretch(), and setItemSpacing().

new void QtGui.QGraphicsLinearLayout.InsertStretch ( int  index,
int  stretch = 1 
)

Inserts a stretch of stretch at index, or before any item that is currently at index.

See also addStretch(), setStretchFactor(), setItemSpacing(), and insertItem().

override void QtGui.QGraphicsLinearLayout.Invalidate ( )
virtual

Reimplemented from QGraphicsLayout::invalidate().

Reimplemented from QtGui.QGraphicsLayout.

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

Reimplemented from QGraphicsLayout::itemAt().

When iterating from 0 and up, it will return the items in the visual arranged order.

Implements QtGui.QGraphicsLayout.

new double QtGui.QGraphicsLinearLayout.ItemSpacing ( int  index)

Returns the spacing after item at index.

See also setItemSpacing().

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

Reimplemented from QGraphicsLayout::removeAt().

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

See also removeItem() and insertItem().

Implements QtGui.QGraphicsLayout.

new void QtGui.QGraphicsLinearLayout.RemoveItem ( IQGraphicsLayoutItem  item)

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

See also removeAt() and insertItem().

new void QtGui.QGraphicsLinearLayout.SetAlignment ( IQGraphicsLayoutItem  item,
Qt.AlignmentFlag  alignment 
)

Sets the alignment of item to alignment. If item's alignment changes, the layout is automatically invalidated.

See also alignment() and invalidate().

new void QtGui.QGraphicsLinearLayout.SetItemSpacing ( int  index,
double  spacing 
)

Sets the spacing after item at index to spacing.

See also itemSpacing().

new void QtGui.QGraphicsLinearLayout.SetStretchFactor ( IQGraphicsLayoutItem  item,
int  stretch 
)

Sets the stretch factor for item to stretch. If an item's stretch factor changes, this function will invalidate the layout.

Setting stretch to 0 removes the stretch factor from the item, and is effectively equivalent to setting stretch to 1.

See also stretchFactor().

new QSizeF QtGui.QGraphicsLinearLayout.SizeHint ( Qt.SizeHint  which)

Reimplemented from QGraphicsLayoutItem::sizeHint().

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

Reimplemented from QGraphicsLayoutItem::sizeHint().

Implements QtGui.QGraphicsLayoutItem.

new int QtGui.QGraphicsLinearLayout.StretchFactor ( IQGraphicsLayoutItem  item)

Returns the stretch factor for item. The default stretch factor is 0, meaning that the item has no assigned stretch factor.

See also setStretchFactor().

Property Documentation

override QRectF QtGui.QGraphicsLinearLayout.Geometry
getset

Reimplemented from QGraphicsLayoutItem::setGeometry().

new Qt.Orientation QtGui.QGraphicsLinearLayout.Orientation
getset

Returns the layout orientation.

Change the layout orientation to orientation. Changing the layout orientation will automatically invalidate the layout.

new double QtGui.QGraphicsLinearLayout.Spacing
getset

Returns the layout's spacing. Spacing refers to the vertical and horizontal distances between items.

Sets the layout's spacing to spacing. Spacing refers to the vertical and horizontal distances between items.