QSpacerItem 类

QSpacerItem 类在布局中提供空白空间。 更多...

头: #include <QSpacerItem>
CMake: find_package(Qt6 COMPONENTS Widgets REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: QLayoutItem

公共函数

  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

重实现公共函数

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

详细描述

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:

函数
QHBoxLayout addSpacing() , addStretch() , insertSpacing() , insertStretch()
QGridLayout setRowMinimumHeight() , setRowStretch() , setColumnMinimumWidth() , setColumnStretch()

另请参阅 QLayout , QWidgetItem ,和 QLayoutItem::spacerItem ().

成员函数文档编制

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.

[虚拟] QSpacerItem:: ~QSpacerItem ()

析构函数。

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.

另请参阅 QSpacerItem::invalidate ().

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

重实现: QLayoutItem::expandingDirections () const.

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

重实现: QLayoutItem::geometry () const.

另请参阅 setGeometry ().

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

重实现: QLayoutItem::isEmpty () const.

返回 true .

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

重实现: QLayoutItem::maximumSize () const.

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

重实现: QLayoutItem::minimumSize () const.

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

重实现: QLayoutItem::setGeometry (const QRect &r).

另请参阅 geometry ().

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

重实现: QLayoutItem::sizeHint () const.

[since 5.5] QSizePolicy QSpacerItem:: sizePolicy () const

返回此项的大小策略。

该函数在 Qt 5.5 引入。

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

重实现: QLayoutItem::spacerItem ().

返回指向此对象的指针。