Qt 4.8
Public Functions | Properties | List of all members
QSpacerItem Class Reference

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

#include <qlayoutitem.h>

Inheritance diagram for QSpacerItem:
QLayoutItem

Public Functions

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. More...
 
Qt::Orientations expandingDirections () const
 Reimplemented Function More...
 
QRect geometry () const
 Reimplemented Function More...
 
bool isEmpty () const
 Returns true. More...
 
QSize maximumSize () const
 Reimplemented Function More...
 
QSize minimumSize () const
 Reimplemented Function More...
 
 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. More...
 
void setGeometry (const QRect &)
 Reimplemented Function More...
 
QSize sizeHint () const
 Reimplemented Function More...
 
QSpacerItemspacerItem ()
 Returns a pointer to this object. More...
 
- Public Functions inherited from QLayoutItem
Qt::Alignment alignment () const
 Returns the alignment of this item. More...
 
QSizePolicy::ControlTypes controlTypes () const
 Returns the control type(s) for the layout item. More...
 
virtual bool hasHeightForWidth () const
 Returns true if this layout's preferred height depends on its width; otherwise returns false. More...
 
virtual int heightForWidth (int) const
 Returns the preferred height for this layout item, given the width w. More...
 
virtual void invalidate ()
 Invalidates any cached information in this layout item. More...
 
virtual QLayoutlayout ()
 If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned. More...
 
virtual int minimumHeightForWidth (int) const
 Returns the minimum height this widget needs for the given width, w. More...
 
 QLayoutItem (Qt::Alignment alignment=0)
 Constructs a layout item with an alignment. More...
 
void setAlignment (Qt::Alignment a)
 Sets the alignment of this item to alignment. More...
 
virtual QWidgetwidget ()
 If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned. More...
 
virtual ~QLayoutItem ()
 Destroys the QLayoutItem. More...
 

Properties

int height
 
QRect rect
 
QSizePolicy sizeP
 
int width
 

Additional Inherited Members

- Protected Variables inherited from QLayoutItem
Qt::Alignment align
 

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, QLayoutItem::spacerItem()

Definition at line 96 of file qlayoutitem.h.

Constructors and Destructors

◆ 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 99 of file qlayoutitem.h.

102  : width(w), height(h), sizeP(hData, vData) { }
QSizePolicy sizeP
Definition: qlayoutitem.h:118

Functions

◆ 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 311 of file qlayoutitem.cpp.

Referenced by QCalendarWidgetPrivate::_q_yearClicked(), QCalendarWidgetPrivate::_q_yearEditingFinished(), changeSpacerSize(), QBoxLayout::setDirection(), QWizardPrivate::updateLayout(), and QComboBoxPrivateContainer::updateTopBottomMargin().

313 {
314  width = w;
315  height = h;
316  sizeP = QSizePolicy(hPolicy, vPolicy);
317 }
QSizePolicy sizeP
Definition: qlayoutitem.h:118

◆ expandingDirections()

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

Reimplemented Function

Implements QLayoutItem.

Definition at line 595 of file qlayoutitem.cpp.

Referenced by QBoxLayout::setDirection().

596 {
597  return sizeP.expandingDirections();
598 }
Qt::Orientations expandingDirections() const
Definition: qsizepolicy.h:126
QSizePolicy sizeP
Definition: qlayoutitem.h:118

◆ geometry()

QRect QSpacerItem::geometry ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 534 of file qlayoutitem.cpp.

535 {
536  return rect;
537 }

◆ isEmpty()

bool QSpacerItem::isEmpty ( ) const
virtual

Returns true.

Implements QLayoutItem.

Definition at line 708 of file qlayoutitem.cpp.

709 {
710  return true;
711 }

◆ maximumSize()

QSize QSpacerItem::maximumSize ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 655 of file qlayoutitem.cpp.

656 {
659 }
Policy horizontalPolicy() const
Definition: qsizepolicy.h:118
QSizePolicy sizeP
Definition: qlayoutitem.h:118
Policy verticalPolicy() const
Definition: qsizepolicy.h:119
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static const int QLAYOUTSIZE_MAX
Definition: qlayoutitem.h:56

◆ minimumSize()

QSize QSpacerItem::minimumSize ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 634 of file qlayoutitem.cpp.

635 {
638 }
Policy horizontalPolicy() const
Definition: qsizepolicy.h:118
QSizePolicy sizeP
Definition: qlayoutitem.h:118
Policy verticalPolicy() const
Definition: qsizepolicy.h:119
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ setGeometry()

void QSpacerItem::setGeometry ( const QRect r)
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 466 of file qlayoutitem.cpp.

467 {
468  rect = r;
469 }

◆ sizeHint()

QSize QSpacerItem::sizeHint ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 678 of file qlayoutitem.cpp.

Referenced by QBoxLayout::setDirection().

679 {
680  return QSize(width, height);
681 }
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ spacerItem()

QSpacerItem * QSpacerItem::spacerItem ( )
virtual

Returns a pointer to this object.

Reimplemented from QLayoutItem.

Definition at line 368 of file qlayoutitem.cpp.

369 {
370  return this;
371 }

Properties

◆ height

int QSpacerItem::height
private

Definition at line 117 of file qlayoutitem.h.

◆ rect

QRect QSpacerItem::rect
private

Definition at line 119 of file qlayoutitem.h.

◆ sizeP

QSizePolicy QSpacerItem::sizeP
private

Definition at line 118 of file qlayoutitem.h.

◆ width

int QSpacerItem::width
private

Definition at line 116 of file qlayoutitem.h.


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