![]() |
Qt 6.x
The Qt SDK
|
The QSpacerItem class provides blank space in a layout. More...
#include <qlayoutitem.h>
Public Member Functions | |
QSpacerItem (int w, int h, QSizePolicy::Policy hData=QSizePolicy::Minimum, QSizePolicy::Policy vData=QSizePolicy::Minimum) | |
Constructs a spacer item with preferred width w, preferred height h, horizontal size policy hPolicy and vertical size policy vPolicy. | |
~QSpacerItem () | |
Destructor. | |
void | changeSize (int w, int h, QSizePolicy::Policy hData=QSizePolicy::Minimum, QSizePolicy::Policy vData=QSizePolicy::Minimum) |
Changes this spacer item to have preferred width w, preferred height h, horizontal size policy hPolicy and vertical size policy vPolicy. | |
QSize | sizeHint () const override |
\reimp | |
QSize | minimumSize () const override |
\reimp | |
QSize | maximumSize () const override |
\reimp | |
Qt::Orientations | expandingDirections () const override |
\reimp | |
bool | isEmpty () const override |
Returns true . | |
void | setGeometry (const QRect &) override |
\reimp | |
QRect | geometry () const override |
\reimp | |
QSpacerItem * | spacerItem () override |
Returns a pointer to this object. | |
QSizePolicy | sizePolicy () const |
![]() | |
QLayoutItem (Qt::Alignment alignment=Qt::Alignment()) | |
Constructs a layout item with an alignment. | |
virtual | ~QLayoutItem () |
Destroys the QLayoutItem. | |
virtual QSize | sizeHint () const =0 |
Implemented in subclasses to return the preferred size of this item. | |
virtual QSize | minimumSize () const =0 |
Implemented in subclasses to return the minimum size of this item. | |
virtual QSize | maximumSize () const =0 |
Implemented in subclasses to return the maximum size of this item. | |
virtual Qt::Orientations | expandingDirections () const =0 |
Returns whether this layout item can make use of more space than sizeHint(). | |
virtual void | setGeometry (const QRect &)=0 |
Implemented in subclasses to set this item's geometry to r. | |
virtual QRect | geometry () const =0 |
Returns the rectangle covered by this layout item. | |
virtual bool | isEmpty () const =0 |
Implemented in subclasses to return whether this item is empty, i.e. | |
virtual bool | hasHeightForWidth () const |
Returns true if this layout's preferred height depends on its width; otherwise returns false . | |
virtual int | heightForWidth (int) const |
Returns the preferred height for this layout item, given the width, which is not used in this default implementation. | |
virtual int | minimumHeightForWidth (int) const |
Returns the minimum height this widget needs for the given width, w. | |
virtual void | invalidate () |
Invalidates any cached information in this layout item. | |
virtual QWidget * | widget () const |
If this item manages a QWidget, returns that widget. | |
virtual QLayout * | layout () |
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned. | |
virtual QSpacerItem * | spacerItem () |
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise \nullptr is returned. | |
Qt::Alignment | alignment () const |
Returns the alignment of this item. | |
void | setAlignment (Qt::Alignment a) |
Sets the alignment of this item to alignment. | |
virtual QSizePolicy::ControlTypes | controlTypes () const |
Returns the control type(s) for the layout item. | |
Additional Inherited Members | |
![]() | |
Qt::Alignment | align |
The QSpacerItem class provides blank space in a layout.
\inmodule QtWidgets
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:
\table \header
Definition at line 56 of file qlayoutitem.h.
|
inline |
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.
Definition at line 59 of file qlayoutitem.h.
QSpacerItem::~QSpacerItem | ( | ) |
Destructor.
Definition at line 225 of file qlayoutitem.cpp.
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.
Definition at line 241 of file qlayoutitem.cpp.
Referenced by QCalendarWidgetPrivate::_q_yearClicked(), QCalendarWidgetPrivate::_q_yearEditingFinished(), changeSpacerSize(), QWizardPrivate::updateLayout(), and QComboBoxPrivateContainer::updateTopBottomMargin().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 575 of file qlayoutitem.cpp.
References QSizePolicy::expandingDirections().
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 633 of file qlayoutitem.cpp.
References QSizePolicy::GrowFlag, QSizePolicy::horizontalPolicy(), QLAYOUTSIZE_MAX, and QSizePolicy::verticalPolicy().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 612 of file qlayoutitem.cpp.
References QSizePolicy::horizontalPolicy(), QSizePolicy::ShrinkFlag, and QSizePolicy::verticalPolicy().
|
overridevirtual |
|
inline |
|
overridevirtual |
Returns a pointer to this object.
Reimplemented from QLayoutItem.
Definition at line 305 of file qlayoutitem.cpp.