QtBase  v6.3.1
Public Member Functions | List of all members
QGraphicsLinearLayout Class Reference

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

#include <qgraphicslinearlayout.h>

Inheritance diagram for QGraphicsLinearLayout:
Inheritance graph
[legend]
Collaboration diagram for QGraphicsLinearLayout:
Collaboration graph
[legend]

Public Member Functions

 QGraphicsLinearLayout (QGraphicsLayoutItem *parent=nullptr)
 
 QGraphicsLinearLayout (Qt::Orientation orientation, QGraphicsLayoutItem *parent=nullptr)
 
virtual ~QGraphicsLinearLayout ()
 
void setOrientation (Qt::Orientation orientation)
 
Qt::Orientation orientation () const
 
void addItem (QGraphicsLayoutItem *item)
 
void addStretch (int stretch=1)
 
void insertItem (int index, QGraphicsLayoutItem *item)
 
void insertStretch (int index, int stretch=1)
 
void removeItem (QGraphicsLayoutItem *item)
 
void removeAt (int index) override
 
void setSpacing (qreal spacing)
 
qreal spacing () const
 
void setItemSpacing (int index, qreal spacing)
 
qreal itemSpacing (int index) const
 
void setStretchFactor (QGraphicsLayoutItem *item, int stretch)
 
int stretchFactor (QGraphicsLayoutItem *item) const
 
void setAlignment (QGraphicsLayoutItem *item, Qt::Alignment alignment)
 
Qt::Alignment alignment (QGraphicsLayoutItem *item) const
 
void setGeometry (const QRectF &rect) override
 
int count () const override
 
QGraphicsLayoutItemitemAt (int index) const override
 
void invalidate () override
 
QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const override
 
void dump (int indent=0) const
 
- Public Member Functions inherited from QGraphicsLayout
 QGraphicsLayout (QGraphicsLayoutItem *parent=nullptr)
 
 ~QGraphicsLayout ()
 
void setContentsMargins (qreal left, qreal top, qreal right, qreal bottom)
 
void getContentsMargins (qreal *left, qreal *top, qreal *right, qreal *bottom) const override
 
void activate ()
 
bool isActivated () const
 
virtual void updateGeometry () override
 
virtual void widgetEvent (QEvent *e)
 
- Public Member Functions inherited from QGraphicsLayoutItem
 QGraphicsLayoutItem (QGraphicsLayoutItem *parent=nullptr, bool isLayout=false)
 
virtual ~QGraphicsLayoutItem ()
 
void setSizePolicy (const QSizePolicy &policy)
 
void setSizePolicy (QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType=QSizePolicy::DefaultType)
 
QSizePolicy sizePolicy () const
 
void setMinimumSize (const QSizeF &size)
 
void setMinimumSize (qreal w, qreal h)
 
QSizeF minimumSize () const
 
void setMinimumWidth (qreal width)
 
qreal minimumWidth () const
 
void setMinimumHeight (qreal height)
 
qreal minimumHeight () const
 
void setPreferredSize (const QSizeF &size)
 
void setPreferredSize (qreal w, qreal h)
 
QSizeF preferredSize () const
 
void setPreferredWidth (qreal width)
 
qreal preferredWidth () const
 
void setPreferredHeight (qreal height)
 
qreal preferredHeight () const
 
void setMaximumSize (const QSizeF &size)
 
void setMaximumSize (qreal w, qreal h)
 
QSizeF maximumSize () const
 
void setMaximumWidth (qreal width)
 
qreal maximumWidth () const
 
void setMaximumHeight (qreal height)
 
qreal maximumHeight () const
 
QRectF geometry () const
 
QRectF contentsRect () const
 
QSizeF effectiveSizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
 
virtual bool isEmpty () const
 
QGraphicsLayoutItemparentLayoutItem () const
 
void setParentLayoutItem (QGraphicsLayoutItem *parent)
 
bool isLayout () const
 
QGraphicsItemgraphicsItem () const
 
bool ownedByLayout () const
 

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< QGraphicsLayoutItemPrivated_ptr
 

Detailed Description

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

Since
4.4

\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.

Constructor & Destructor Documentation

◆ QGraphicsLinearLayout() [1/2]

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() [2/2]

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.

◆ ~QGraphicsLinearLayout()

QGraphicsLinearLayout::~QGraphicsLinearLayout ( )
virtual

Destroys the QGraphicsLinearLayout object.

Definition at line 205 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addItem()

void QGraphicsLinearLayout::addItem ( QGraphicsLayoutItem item)
inline

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

Definition at line 63 of file qgraphicslinearlayout.h.

Here is the caller graph for this function:

◆ addStretch()

void QGraphicsLinearLayout::addStretch ( int  stretch = 1)
inline

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

Definition at line 64 of file qgraphicslinearlayout.h.

◆ alignment()

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.

See also
setAlignment()

Definition at line 455 of file qgraphicslinearlayout.cpp.

Here is the caller graph for this function:

◆ count()

int QGraphicsLinearLayout::count ( ) const
overridevirtual

\reimp

Implements QGraphicsLayout.

Definition at line 471 of file qgraphicslinearlayout.cpp.

Here is the caller graph for this function:

◆ dump()

void QGraphicsLinearLayout::dump ( int  indent = 0) const

Definition at line 552 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertItem()

void QGraphicsLinearLayout::insertItem ( int  index,
QGraphicsLayoutItem item 
)

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

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

Definition at line 267 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertStretch()

void 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(), insertItem()

Definition at line 294 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:

◆ invalidate()

void QGraphicsLinearLayout::invalidate ( )
overridevirtual

\reimp

Reimplemented from QGraphicsLayout.

Reimplemented in TestLayout, and TestLayout.

Definition at line 540 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemAt()

QGraphicsLayoutItem * QGraphicsLinearLayout::itemAt ( int  index) const
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.

Here is the caller graph for this function:

◆ itemSpacing()

qreal QGraphicsLinearLayout::itemSpacing ( int  index) const

Returns the spacing after item at index.

Definition at line 384 of file qgraphicslinearlayout.cpp.

◆ orientation()

Qt::Orientation QGraphicsLinearLayout::orientation ( ) const

Returns the layout orientation.

See also
setOrientation()

Definition at line 241 of file qgraphicslinearlayout.cpp.

Here is the caller graph for this function:

◆ removeAt()

void QGraphicsLinearLayout::removeAt ( int  index)
overridevirtual

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

See also
removeItem(), insertItem()

Implements QGraphicsLayout.

Definition at line 326 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeItem()

void QGraphicsLinearLayout::removeItem ( QGraphicsLayoutItem item)

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

See also
removeAt(), insertItem()

Definition at line 309 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAlignment()

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.

See also
alignment(), invalidate()

Definition at line 436 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:

◆ setGeometry()

void QGraphicsLinearLayout::setGeometry ( const QRectF rect)
overridevirtual

\reimp

Reimplemented from QGraphicsLayoutItem.

Reimplemented in TestLayout, and AnimatedLayout.

Definition at line 497 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setItemSpacing()

void QGraphicsLinearLayout::setItemSpacing ( int  index,
qreal  spacing 
)

Sets the spacing after item at index to spacing.

Definition at line 375 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:

◆ setOrientation()

void QGraphicsLinearLayout::setOrientation ( Qt::Orientation  orientation)

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

See also
orientation()

Definition at line 227 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:

◆ setSpacing()

void QGraphicsLinearLayout::setSpacing ( qreal  spacing)

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

See also
setItemSpacing(), setStretchFactor(), QGraphicsGridLayout::setSpacing()

Definition at line 349 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setStretchFactor()

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.

See also
stretchFactor()

Definition at line 399 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sizeHint()

QSizeF QGraphicsLinearLayout::sizeHint ( Qt::SizeHint  which,
const QSizeF constraint = QSizeF() 
) const
overridevirtual

\reimp

Implements QGraphicsLayoutItem.

Definition at line 528 of file qgraphicslinearlayout.cpp.

Here is the call graph for this function:

◆ spacing()

qreal QGraphicsLinearLayout::spacing ( ) const

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

See also
setSpacing()

Definition at line 366 of file qgraphicslinearlayout.cpp.

Here is the caller graph for this function:

◆ stretchFactor()

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.

See also
setStretchFactor()

Definition at line 419 of file qgraphicslinearlayout.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: