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
QWidgetItem Class Reference

The QWidgetItem class is a layout item that represents a widget. More...

#include <qlayoutitem.h>

+ Inheritance diagram for QWidgetItem:
+ Collaboration diagram for QWidgetItem:

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
 
QWidgetwidget () 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.
 
- 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 void invalidate ()
 Invalidates any cached information in this layout item.
 
virtual QLayoutlayout ()
 If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
 
virtual QSpacerItemspacerItem ()
 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.
 

Protected Attributes

QWidgetwid
 
- Protected Attributes inherited from QLayoutItem
Qt::Alignment align
 

Detailed Description

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

See also
QLayout, QSpacerItem, QLayoutItem::widget()

Definition at line 85 of file qlayoutitem.h.

Constructor & Destructor Documentation

◆ QWidgetItem()

QWidgetItem::QWidgetItem ( QWidget * w)
inlineexplicit

Creates an item containing the given widget.

Definition at line 90 of file qlayoutitem.h.

◆ ~QWidgetItem()

QWidgetItem::~QWidgetItem ( )
default

Destructor.

Member Function Documentation

◆ controlTypes()

QSizePolicy::ControlTypes QWidgetItem::controlTypes ( ) const
overridevirtual

Returns the control type associated with the widget for which this size policy applies.

See also
QSizePolicy::controlType()

Reimplemented from QLayoutItem.

Definition at line 707 of file qlayoutitem.cpp.

References QSizePolicy::controlType(), QWidget::sizePolicy, and wid.

+ Here is the call graph for this function:

◆ expandingDirections()

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

\reimp

Implements QLayoutItem.

Definition at line 583 of file qlayoutitem.cpp.

References QLayoutItem::align, Qt::AlignHorizontal_Mask, Qt::AlignVertical_Mask, QSizePolicy::expandingDirections(), QLayout::expandingDirections(), QSizePolicy::GrowFlag, Qt::Horizontal, QSizePolicy::horizontalPolicy(), isEmpty(), QWidget::layout(), QWidget::sizePolicy, Qt::Vertical, QSizePolicy::verticalPolicy(), and wid.

+ Here is the call graph for this function:

◆ geometry()

QRect QWidgetItem::geometry ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Definition at line 492 of file qlayoutitem.cpp.

References QWidget::geometry, QWidget::testAttribute(), toLayoutItemRect(), Qt::WA_LayoutUsesWidgetRect, and wid.

+ Here is the call graph for this function:

◆ hasHeightForWidth()

bool QWidgetItem::hasHeightForWidth ( ) const
overridevirtual

\reimp

Reimplemented from QLayoutItem.

Definition at line 503 of file qlayoutitem.cpp.

References QWidget::hasHeightForWidth(), isEmpty(), and wid.

Referenced by setGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ heightForWidth()

int QWidgetItem::heightForWidth ( int w) const
overridevirtual

\reimp

Reimplemented from QLayoutItem.

Reimplemented in QWidgetItemV2.

Definition at line 513 of file qlayoutitem.cpp.

References fromLayoutItemSize(), QWidget::heightForWidth(), isEmpty(), QWidget::layout(), QWidget::maximumHeight, QWidget::minimumHeight, QWidget::testAttribute(), toLayoutItemSize(), QLayout::totalHeightForWidth(), Qt::WA_LayoutUsesWidgetRect, and wid.

Referenced by QWidgetItemV2::heightForWidth(), and setGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEmpty()

bool QWidgetItem::isEmpty ( ) const
overridevirtual

Returns true if the widget is hidden; otherwise returns false.

See also
QWidget::isHidden()

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maximumSize()

QSize QWidgetItem::maximumSize ( ) const
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minimumHeightForWidth()

int QWidgetItem::minimumHeightForWidth ( int w) const
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(), QWidget::heightForWidth(), isEmpty(), QWidget::layout(), QWidget::maximumHeight, QWidget::minimumHeight, QWidget::testAttribute(), toLayoutItemSize(), QLayout::totalMinimumHeightForWidth(), Qt::WA_LayoutUsesWidgetRect, and wid.

+ Here is the call graph for this function:

◆ minimumSize()

QSize QWidgetItem::minimumSize ( ) const
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGeometry()

◆ sizeHint()

QSize QWidgetItem::sizeHint ( ) const
overridevirtual

\reimp

Implements QLayoutItem.

Reimplemented in QWidgetItemV2.

Definition at line 664 of file qlayoutitem.cpp.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ widget()

QWidget * QWidgetItem::widget ( ) const
overridevirtual

Returns the widget managed by this item.

Reimplemented from QLayoutItem.

Definition at line 335 of file qlayoutitem.cpp.

References wid.

Member Data Documentation

◆ wid


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