QSpacerItem Class

The QSpacerItem class provides blank space in a layout. More...

Header: #include <QSpacerItem>
qmake: QT += widgets
Inherits: QLayoutItem

Public Functions

QSpacerItem(int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum)
virtual ~QSpacerItem()
void changeSize(int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum)
QSizePolicy sizePolicy() const

Reimplemented Public Functions

virtual Qt::Orientations expandingDirections() const override
virtual QRect geometry() const override
virtual bool isEmpty() const override
virtual QSize maximumSize() const override
virtual QSize minimumSize() const override
virtual void setGeometry(const QRect &r) override
virtual QSize sizeHint() const override
virtual QSpacerItem * spacerItem() override

Detailed Description

The QSpacerItem class provides blank space in a layout.

Normally, you don't need to use this class directly. Qt's built-in layout managers provide the following functions for manipulating empty space in layouts:

Class Functions
QHBoxLayout addSpacing(), addStretch(), insertSpacing(), insertStretch()
QGridLayout setRowMinimumHeight(), setRowStretch(), setColumnMinimumWidth(), setColumnStretch()

See also QLayout, QWidgetItem, and QLayoutItem::spacerItem().

Member Function Documentation

QSpacerItem::QSpacerItem(int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum)

Constructs a spacer item with preferred width w, preferred height h, horizontal size policy hPolicy and vertical size policy vPolicy.

The default values provide a gap that is able to stretch if nothing else wants the space.

[virtual] QSpacerItem::~QSpacerItem()

Destructor.

void QSpacerItem::changeSize(int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum)

Changes this spacer item to have preferred width w, preferred height h, horizontal size policy hPolicy and vertical size policy vPolicy.

The default values provide a gap that is able to stretch if nothing else wants the space.

Note that if changeSize() is called after the spacer item has been added to a layout, it is necessary to invalidate the layout in order for the spacer item's new size to take effect.

See also QSpacerItem::invalidate().

[override virtual] Qt::Orientations QSpacerItem::expandingDirections() const

Reimplemented from QLayoutItem::expandingDirections().

[override virtual] QRect QSpacerItem::geometry() const

Reimplemented from QLayoutItem::geometry().

See also setGeometry().

[override virtual] bool QSpacerItem::isEmpty() const

Reimplemented from QLayoutItem::isEmpty().

Returns true.

[override virtual] QSize QSpacerItem::maximumSize() const

Reimplemented from QLayoutItem::maximumSize().

[override virtual] QSize QSpacerItem::minimumSize() const

Reimplemented from QLayoutItem::minimumSize().

[override virtual] void QSpacerItem::setGeometry(const QRect &r)

Reimplemented from QLayoutItem::setGeometry().

See also geometry().

[override virtual] QSize QSpacerItem::sizeHint() const

Reimplemented from QLayoutItem::sizeHint().

QSizePolicy QSpacerItem::sizePolicy() const

Returns the size policy of this item.

This function was introduced in Qt 5.5.

[override virtual] QSpacerItem *QSpacerItem::spacerItem()

Reimplemented from QLayoutItem::spacerItem().

Returns a pointer to this object.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.12/qspaceritem.html