Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QSpacerItem Class Reference

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

#include <qlayoutitem.h>

+ Inheritance diagram for QSpacerItem:
+ Collaboration diagram for QSpacerItem:

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
 
QSpacerItemspacerItem () override
 Returns a pointer to this object.
 
QSizePolicy sizePolicy () const
 
- Public Member Functions inherited from QLayoutItem
 QLayoutItem (Qt::Alignment alignment=Qt::Alignment())
 Constructs a layout item with an alignment.
 
virtual ~QLayoutItem ()
 Destroys the QLayoutItem.
 
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 QWidgetwidget () const
 If this item manages a QWidget, returns that widget.
 
virtual QLayoutlayout ()
 If this item is a QLayout, it is returned as a QLayout; 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

- Protected Attributes inherited from QLayoutItem
Qt::Alignment align
 

Detailed Description

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

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

Definition at line 56 of file qlayoutitem.h.

Constructor & Destructor Documentation

◆ QSpacerItem()

QSpacerItem::QSpacerItem ( int w,
int h,
QSizePolicy::Policy hPolicy = QSizePolicy::Minimum,
QSizePolicy::Policy vPolicy = QSizePolicy::Minimum )
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::~QSpacerItem ( )

Destructor.

Definition at line 225 of file qlayoutitem.cpp.

Member Function Documentation

◆ changeSize()

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()

Definition at line 241 of file qlayoutitem.cpp.

Referenced by QCalendarWidgetPrivate::_q_yearClicked(), QCalendarWidgetPrivate::_q_yearEditingFinished(), and QComboBoxPrivateContainer::updateTopBottomMargin().

+ Here is the caller graph for this function:

◆ expandingDirections()

Qt::Orientations QSpacerItem::expandingDirections ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 575 of file qlayoutitem.cpp.

References QSizePolicy::expandingDirections().

+ Here is the call graph for this function:

◆ geometry()

QRect QSpacerItem::geometry ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 484 of file qlayoutitem.cpp.

◆ isEmpty()

bool QSpacerItem::isEmpty ( ) const
overridevirtual

Returns true.

Implements QLayoutItem.

Definition at line 686 of file qlayoutitem.cpp.

◆ maximumSize()

QSize QSpacerItem::maximumSize ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 633 of file qlayoutitem.cpp.

References QSizePolicy::GrowFlag, QSizePolicy::horizontalPolicy(), QLAYOUTSIZE_MAX, and QSizePolicy::verticalPolicy().

+ Here is the call graph for this function:

◆ minimumSize()

QSize QSpacerItem::minimumSize ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 612 of file qlayoutitem.cpp.

References QSizePolicy::horizontalPolicy(), QSizePolicy::ShrinkFlag, and QSizePolicy::verticalPolicy().

+ Here is the call graph for this function:

◆ setGeometry()

void QSpacerItem::setGeometry ( const QRect & r)
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 405 of file qlayoutitem.cpp.

◆ sizeHint()

QSize QSpacerItem::sizeHint ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 656 of file qlayoutitem.cpp.

◆ sizePolicy()

QSizePolicy QSpacerItem::sizePolicy ( ) const
inline
Since
5.5

Returns the size policy of this item.

Definition at line 76 of file qlayoutitem.h.

◆ spacerItem()

QSpacerItem * QSpacerItem::spacerItem ( )
overridevirtual

Returns a pointer to this object.

Reimplemented from QLayoutItem.

Definition at line 305 of file qlayoutitem.cpp.

Referenced by QComboBoxPrivateContainer::updateTopBottomMargin().

+ Here is the caller graph for this function:

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