![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QLayoutItem class provides an abstract item that a QLayout manipulates. More...
#include <qlayoutitem.h>
Public Member Functions | |
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 | |
Qt::Alignment | align |
The QLayoutItem class provides an abstract item that a QLayout manipulates.
\inmodule QtWidgets
This is used by custom layouts.
Pure virtual functions are provided to return information about the layout, including, sizeHint(), minimumSize(), maximumSize() and expandingDirections().
The layout's geometry can be set and retrieved with setGeometry() and geometry(), and its alignment with setAlignment() and alignment().
isEmpty() returns whether the layout item is empty. If the concrete item is a QWidget, it can be retrieved using widget(). Similarly for layout() and spacerItem().
Some layouts have width and height interdependencies. These can be expressed using hasHeightForWidth(), heightForWidth(), and minimumHeightForWidth(). For more explanation see the {Qt Quarterly} article \l{http://doc.qt.io/archives/qq/qq04-height-for-width.html}{Trading Height for Width}.
Definition at line 25 of file qlayoutitem.h.
|
inlineexplicit |
Constructs a layout item with an alignment.
Not all subclasses support alignment.
Definition at line 54 of file qlayoutitem.h.
|
virtualdefault |
Destroys the QLayoutItem.
|
inline |
Returns the alignment of this item.
Definition at line 46 of file qlayoutitem.h.
|
virtual |
Returns the control type(s) for the layout item.
For a QWidgetItem, the control type comes from the widget's size policy; for a QLayoutItem, the control types is derived from the layout's contents.
Reimplemented in QLayout, and QWidgetItem.
Definition at line 392 of file qlayoutitem.cpp.
|
pure virtual |
Returns whether this layout item can make use of more space than sizeHint().
A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, whereas Qt::Vertical | Qt::Horizontal means that it wants to grow in both dimensions.
Implemented in QBoxLayout, qdesigner_internal::PaddingSpacerItem, qdesigner_internal::PaddingSpacerItem, QFormLayout, QGridLayout, QLayout, QSpacerItem, QToolBarLayout, and QWidgetItem.
|
pure virtual |
Returns the rectangle covered by this layout item.
Implemented in QLayout, QSpacerItem, and QWidgetItem.
|
virtual |
Returns true
if this layout's preferred height depends on its width; otherwise returns false
.
The default implementation returns false.
Reimplement this function in layout managers that support height for width.
Reimplemented in QBoxLayout, QFormLayout, QGridLayout, QStackedLayout, and QWidgetItem.
Definition at line 345 of file qlayoutitem.cpp.
|
virtual |
Returns the preferred height for this layout item, given the width, which is not used in this default implementation.
The default implementation returns -1, indicating that the preferred height is independent of the width of the item. Using the function hasHeightForWidth() will typically be much faster than calling this function and testing for -1.
Reimplement this function in layout managers that support height for width. A typical implementation will look like this:
Caching is strongly recommended; without it layout will take exponential time.
Reimplemented in QBoxLayout, QFormLayout, QGridLayout, QStackedLayout, QWidgetItem, and QWidgetItemV2.
Definition at line 379 of file qlayoutitem.cpp.
|
virtual |
Invalidates any cached information in this layout item.
Reimplemented in QBoxLayout, QFormLayout, QGridLayout, QLayout, QMainWindowLayout, and QToolBarLayout.
Definition at line 263 of file qlayoutitem.cpp.
|
pure virtual |
Implemented in subclasses to return whether this item is empty, i.e.
whether it contains any widgets.
Implemented in QLayout, QSpacerItem, QToolBarItem, QToolBarLayout, and QWidgetItem.
|
virtual |
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
This function provides type-safe casting.
Reimplemented in QLayout.
Definition at line 273 of file qlayoutitem.cpp.
|
pure virtual |
Implemented in subclasses to return the maximum size of this item.
Implemented in QBoxLayout, QDockWidgetItem, QDockWidgetLayout, QGridLayout, QLayout, QSpacerItem, QWidgetItem, and QWidgetItemV2.
|
virtual |
Returns the minimum height this widget needs for the given width, w.
The default implementation simply returns heightForWidth(w).
Reimplemented in QBoxLayout, QGridLayout, and QWidgetItem.
Definition at line 355 of file qlayoutitem.cpp.
|
pure virtual |
Implemented in subclasses to return the minimum size of this item.
Implemented in CardLayout, CardLayout, QBoxLayout, qdesigner_internal::QDesignerWidgetItem, QDockWidgetItem, QDockWidgetLayout, QFormLayout, QGridLayout, QLayout, QMainWindowLayout, QSpacerItem, QStackedLayout, QToolBarLayout, QWidgetItem, and QWidgetItemV2.
void QLayoutItem::setAlignment | ( | Qt::Alignment | alignment | ) |
Sets the alignment of this item to alignment.
{Note:} Item alignment is only supported by QLayoutItem subclasses where it would have a visual effect. Except for QSpacerItem, which provides blank space for layouts, all public Qt classes that inherit QLayoutItem support item alignment.
Definition at line 151 of file qlayoutitem.cpp.
Implemented in subclasses to set this item's geometry to r.
Implemented in CardLayout, CardLayout, QBoxLayout, QDockWidgetLayout, QFormLayout, QGridLayout, QLayout, QMainWindowLayout, QSpacerItem, QStackedLayout, QToolBarLayout, and QWidgetItem.
|
pure virtual |
Implemented in subclasses to return the preferred size of this item.
Implemented in CardLayout, CardLayout, QBoxLayout, qdesigner_internal::QDesignerWidgetItem, QDockWidgetItem, QDockWidgetLayout, QFormLayout, QGridLayout, QMainWindowLayout, QSpacerItem, QStackedLayout, QToolBarLayout, QWidgetItem, and QWidgetItemV2.
|
virtual |
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise \nullptr is returned.
This function provides type-safe casting.
Reimplemented in QSpacerItem.
Definition at line 284 of file qlayoutitem.cpp.
|
virtual |
If this item manages a QWidget, returns that widget.
Otherwise, \nullptr is returned.
Reimplemented in QWidgetItem.
Definition at line 322 of file qlayoutitem.cpp.
|
protected |
Definition at line 51 of file qlayoutitem.h.