![]() |
Qt 6.x
The Qt SDK
|
The QWidgetItem class is a layout item that represents a widget. More...
#include <qlayoutitem.h>
Public Member Functions | |
QWidgetItem (QWidget *w) | |
Creates an item containing the given widget. | |
~QWidgetItem () | |
Destructor. | |
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 if the widget is hidden; otherwise returns false . | |
void | setGeometry (const QRect &) override |
\reimp | |
QRect | geometry () const override |
\reimp | |
QWidget * | widget () const override |
Returns the widget managed by this item. | |
bool | hasHeightForWidth () const override |
\reimp | |
int | heightForWidth (int) const override |
\reimp | |
int | minimumHeightForWidth (int) const override |
Returns the minimum height this widget needs for the given width, w. | |
QSizePolicy::ControlTypes | controlTypes () const override |
Returns the control type associated with the widget for which this size policy applies. | |
![]() | |
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. | |
Protected Attributes | |
QWidget * | wid |
![]() | |
Qt::Alignment | align |
The QWidgetItem class is a layout item that represents a widget.
\inmodule QtWidgets
Normally, you don't need to use this class directly. Qt's built-in layout managers provide the following functions for manipulating widgets in layouts:
\table \header
Definition at line 85 of file qlayoutitem.h.
|
inlineexplicit |
Creates an item containing the given widget.
Definition at line 90 of file qlayoutitem.h.
|
default |
Destructor.
|
overridevirtual |
Returns the control type associated with the widget for which this size policy applies.
Reimplemented from QLayoutItem.
Definition at line 707 of file qlayoutitem.cpp.
References QSizePolicy::controlType(), QWidget::sizePolicy, and wid.
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 583 of file qlayoutitem.cpp.
References QLayoutItem::align, Qt::AlignHorizontal_Mask, Qt::AlignVertical_Mask, e, QSizePolicy::expandingDirections(), QLayout::expandingDirections(), QSizePolicy::GrowFlag, Qt::Horizontal, QSizePolicy::horizontalPolicy(), isEmpty(), QWidget::layout(), QWidget::sizePolicy, Qt::Vertical, QSizePolicy::verticalPolicy(), and wid.
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 492 of file qlayoutitem.cpp.
References QWidget::geometry, QWidget::testAttribute(), toLayoutItemRect(), Qt::WA_LayoutUsesWidgetRect, and wid.
|
overridevirtual |
\reimp
Reimplemented from QLayoutItem.
Definition at line 503 of file qlayoutitem.cpp.
References QWidget::hasHeightForWidth(), isEmpty(), and wid.
Referenced by setGeometry().
|
overridevirtual |
\reimp
Reimplemented from QLayoutItem.
Reimplemented in QWidgetItemV2.
Definition at line 513 of file qlayoutitem.cpp.
References fromLayoutItemSize(), QSize::height(), QWidget::heightForWidth(), isEmpty(), QWidget::layout(), QWidget::maximumHeight, QWidget::minimumHeight, QWidget::testAttribute(), toLayoutItemSize(), QLayout::totalHeightForWidth(), Qt::WA_LayoutUsesWidgetRect, wid, and QSize::width().
Referenced by QWidgetItemV2::heightForWidth(), and setGeometry().
|
overridevirtual |
Returns true
if the widget is hidden; otherwise returns false
.
Implements QLayoutItem.
Definition at line 696 of file qlayoutitem.cpp.
References QWidget::isHidden(), QWidget::isWindow(), QSizePolicy::retainSizeWhenHidden(), QWidget::sizePolicy, and wid.
Referenced by expandingDirections(), hasHeightForWidth(), QWidgetItemV2::heightForWidth(), heightForWidth(), maximumSize(), QWidgetItemV2::maximumSize(), minimumHeightForWidth(), minimumSize(), QWidgetItemV2::minimumSize(), setGeometry(), sizeHint(), and QWidgetItemV2::sizeHint().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Reimplemented in QWidgetItemV2.
Definition at line 642 of file qlayoutitem.cpp.
References QLayoutItem::align, isEmpty(), qSmartMaxSize(), QWidget::testAttribute(), toLayoutItemSize(), Qt::WA_LayoutUsesWidgetRect, and wid.
Referenced by QWidgetItemV2::maximumSize(), and setGeometry().
|
overridevirtual |
Returns the minimum height this widget needs for the given width, w.
The default implementation simply returns heightForWidth(w).
Reimplemented from QLayoutItem.
Definition at line 542 of file qlayoutitem.cpp.
References fromLayoutItemSize(), QSize::height(), QWidget::heightForWidth(), isEmpty(), QWidget::layout(), QWidget::maximumHeight, QWidget::minimumHeight, QWidget::testAttribute(), toLayoutItemSize(), QLayout::totalMinimumHeightForWidth(), Qt::WA_LayoutUsesWidgetRect, wid, and QSize::width().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Reimplemented in QWidgetItemV2.
Definition at line 621 of file qlayoutitem.cpp.
References isEmpty(), qSmartMinSize(), QWidget::testAttribute(), toLayoutItemSize(), Qt::WA_LayoutUsesWidgetRect, and wid.
Referenced by QWidgetItemV2::minimumSize().
\reimp
Implements QLayoutItem.
Definition at line 413 of file qlayoutitem.cpp.
References QLayoutItem::align, Qt::AlignBottom, Qt::AlignHorizontal_Mask, Qt::AlignLeft, Qt::AlignRight, Qt::AlignTop, Qt::AlignVertical_Mask, QSize::boundedTo(), QSize::expandedTo(), fromLayoutItemRect(), hasHeightForWidth(), QSize::height(), heightForWidth(), QSizePolicy::Ignored, isEmpty(), QWidget::layoutDirection, maximumSize(), QWidget::minimumSize, qMin(), rect, QWidget::setGeometry(), QSize::setHeight(), QSize::setWidth(), sizeHint(), QWidget::sizeHint, QWidget::sizePolicy, sp, QWidget::testAttribute(), QStyle::visualAlignment(), Qt::WA_LayoutUsesWidgetRect, wid, and QSize::width().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Reimplemented in QWidgetItemV2.
Definition at line 664 of file qlayoutitem.cpp.
References QSize::boundedTo(), QSize::expandedTo(), QSizePolicy::horizontalPolicy(), QSizePolicy::Ignored, isEmpty(), QWidget::maximumSize, QWidget::minimumSize, QWidget::minimumSizeHint, QWidget::sizeHint, QWidget::sizePolicy, QWidget::testAttribute(), toLayoutItemSize(), QSizePolicy::verticalPolicy(), Qt::WA_LayoutUsesWidgetRect, and wid.
Referenced by QToolBarLayout::expandedSize(), QToolBarLayout::layoutActions(), setGeometry(), QWidgetItemV2::sizeHint(), and QDockWidgetItem::sizeHint().
|
overridevirtual |
Returns the widget managed by this item.
Reimplemented from QLayoutItem.
Definition at line 335 of file qlayoutitem.cpp.
References wid.
|
protected |
Definition at line 107 of file qlayoutitem.h.
Referenced by QWidgetItemV2::QWidgetItemV2(), QWidgetItemV2::~QWidgetItemV2(), QWidgetPrivate::~QWidgetPrivate(), controlTypes(), expandingDirections(), geometry(), hasHeightForWidth(), heightForWidth(), isEmpty(), maximumSize(), minimumHeightForWidth(), minimumSize(), setGeometry(), sizeHint(), and widget().