QtBase
v6.3.1
|
The QGraphicsLinearLayout class provides a horizontal or vertical layout for managing widgets in Graphics View. More...
#include <qgraphicslinearlayout.h>
Additional Inherited Members | |
Static Public Member Functions inherited from QGraphicsLayout | |
static void | setInstantInvalidatePropagation (bool enable) |
static bool | instantInvalidatePropagation () |
Protected Member Functions inherited from QGraphicsLayout | |
QGraphicsLayout (QGraphicsLayoutPrivate &, QGraphicsLayoutItem *) | |
void | addChildLayoutItem (QGraphicsLayoutItem *layoutItem) |
Protected Member Functions inherited from QGraphicsLayoutItem | |
void | setGraphicsItem (QGraphicsItem *item) |
void | setOwnedByLayout (bool ownedByLayout) |
QGraphicsLayoutItem (QGraphicsLayoutItemPrivate &dd) | |
Protected Attributes inherited from QGraphicsLayoutItem | |
QScopedPointer< QGraphicsLayoutItemPrivate > | d_ptr |
The QGraphicsLinearLayout class provides a horizontal or vertical layout for managing widgets in Graphics View.
\inmodule QtWidgets
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().
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.
Definition at line 53 of file qgraphicslinearlayout.h.
QGraphicsLinearLayout::QGraphicsLinearLayout | ( | QGraphicsLayoutItem * | parent = nullptr | ) |
Constructs a QGraphicsLinearLayout instance using Qt::Horizontal orientation. parent is passed to QGraphicsLayout's constructor.
Definition at line 197 of file qgraphicslinearlayout.cpp.
QGraphicsLinearLayout::QGraphicsLinearLayout | ( | Qt::Orientation | orientation, |
QGraphicsLayoutItem * | parent = nullptr |
||
) |
Constructs a QGraphicsLinearLayout instance. You can pass the orientation for the layout, either horizontal or vertical, and parent is passed to QGraphicsLayout's constructor.
Definition at line 188 of file qgraphicslinearlayout.cpp.
|
virtual |
Destroys the QGraphicsLinearLayout object.
Definition at line 205 of file qgraphicslinearlayout.cpp.
|
inline |
This convenience function is equivalent to calling insertItem(-1, item).
Definition at line 63 of file qgraphicslinearlayout.h.
|
inline |
This convenience function is equivalent to calling insertStretch(-1, stretch).
Definition at line 64 of file qgraphicslinearlayout.h.
Qt::Alignment QGraphicsLinearLayout::alignment | ( | QGraphicsLayoutItem * | item | ) | const |
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.
Definition at line 455 of file qgraphicslinearlayout.cpp.
|
overridevirtual |
\reimp
Implements QGraphicsLayout.
Definition at line 471 of file qgraphicslinearlayout.cpp.
void QGraphicsLinearLayout::dump | ( | int | indent = 0 | ) | const |
Definition at line 552 of file qgraphicslinearlayout.cpp.
void QGraphicsLinearLayout::insertItem | ( | int | index, |
QGraphicsLayoutItem * | item | ||
) |
Inserts item into the layout at index, or before any item that is currently at index.
Definition at line 267 of file qgraphicslinearlayout.cpp.
void QGraphicsLinearLayout::insertStretch | ( | int | index, |
int | stretch = 1 |
||
) |
Inserts a stretch of stretch at index, or before any item that is currently at index.
Definition at line 294 of file qgraphicslinearlayout.cpp.
|
overridevirtual |
\reimp
Reimplemented from QGraphicsLayout.
Reimplemented in TestLayout, and TestLayout.
Definition at line 540 of file qgraphicslinearlayout.cpp.
|
overridevirtual |
\reimp When iterating from 0 and up, it will return the items in the visual arranged order.
Implements QGraphicsLayout.
Definition at line 481 of file qgraphicslinearlayout.cpp.
qreal QGraphicsLinearLayout::itemSpacing | ( | int | index | ) | const |
Returns the spacing after item at index.
Definition at line 384 of file qgraphicslinearlayout.cpp.
Qt::Orientation QGraphicsLinearLayout::orientation | ( | ) | const |
Returns the layout orientation.
Definition at line 241 of file qgraphicslinearlayout.cpp.
|
overridevirtual |
Removes the item at index without destroying it. Ownership of the item is transferred to the caller.
Implements QGraphicsLayout.
Definition at line 326 of file qgraphicslinearlayout.cpp.
void QGraphicsLinearLayout::removeItem | ( | QGraphicsLayoutItem * | item | ) |
Removes item from the layout without destroying it. Ownership of item is transferred to the caller.
Definition at line 309 of file qgraphicslinearlayout.cpp.
void QGraphicsLinearLayout::setAlignment | ( | QGraphicsLayoutItem * | item, |
Qt::Alignment | alignment | ||
) |
Sets the alignment of item to alignment. If item's alignment changes, the layout is automatically invalidated.
Definition at line 436 of file qgraphicslinearlayout.cpp.
\reimp
Reimplemented from QGraphicsLayoutItem.
Reimplemented in TestLayout, and AnimatedLayout.
Definition at line 497 of file qgraphicslinearlayout.cpp.
Sets the spacing after item at index to spacing.
Definition at line 375 of file qgraphicslinearlayout.cpp.
void QGraphicsLinearLayout::setOrientation | ( | Qt::Orientation | orientation | ) |
Change the layout orientation to orientation. Changing the layout orientation will automatically invalidate the layout.
Definition at line 227 of file qgraphicslinearlayout.cpp.
Sets the layout's spacing to spacing. Spacing refers to the vertical and horizontal distances between items.
Definition at line 349 of file qgraphicslinearlayout.cpp.
void QGraphicsLinearLayout::setStretchFactor | ( | QGraphicsLayoutItem * | 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.
Definition at line 399 of file qgraphicslinearlayout.cpp.
|
overridevirtual |
\reimp
Implements QGraphicsLayoutItem.
Definition at line 528 of file qgraphicslinearlayout.cpp.
qreal QGraphicsLinearLayout::spacing | ( | ) | const |
Returns the layout's spacing. Spacing refers to the vertical and horizontal distances between items.
Definition at line 366 of file qgraphicslinearlayout.cpp.
int QGraphicsLinearLayout::stretchFactor | ( | QGraphicsLayoutItem * | item | ) | const |
Returns the stretch factor for item. The default stretch factor is 0, meaning that the item has no assigned stretch factor.
Definition at line 419 of file qgraphicslinearlayout.cpp.