QtBase
v6.3.1
|
The QLayoutItem class provides an abstract item that a QLayout manipulates. More...
#include <qlayoutitem.h>
Public Member Functions | |
QLayoutItem (Qt::Alignment alignment=Qt::Alignment()) | |
virtual | ~QLayoutItem () |
virtual QSize | sizeHint () const =0 |
virtual QSize | minimumSize () const =0 |
virtual QSize | maximumSize () const =0 |
virtual Qt::Orientations | expandingDirections () const =0 |
virtual void | setGeometry (const QRect &)=0 |
virtual QRect | geometry () const =0 |
virtual bool | isEmpty () const =0 |
virtual bool | hasHeightForWidth () const |
virtual int | heightForWidth (int) const |
virtual int | minimumHeightForWidth (int) const |
virtual void | invalidate () |
virtual QWidget * | widget () const |
virtual QLayout * | layout () |
virtual QSpacerItem * | spacerItem () |
Qt::Alignment | alignment () const |
void | setAlignment (Qt::Alignment a) |
virtual QSizePolicy::ControlTypes | controlTypes () const |
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 expanding().
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 60 of file qlayoutitem.h.
|
inlineexplicit |
Constructs a layout item with an alignment. Not all subclasses support alignment.
Definition at line 89 of file qlayoutitem.h.
|
virtualdefault |
Destroys the QLayoutItem.
|
inline |
Returns the alignment of this item.
Definition at line 81 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 QWidgetItem, and QLayout.
Definition at line 433 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 LayoutItem, QToolBarLayout, QWidgetItem, QSpacerItem, QLayout, QGridLayout, QFormLayout, QBoxLayout, FlowLayout, and BorderLayout.
|
pure virtual |
Returns the rectangle covered by this layout item.
Implemented in LayoutItem, QWidgetItem, QSpacerItem, and QLayout.
|
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 QStackedLayout, QWidgetItem, QGridLayout, QFormLayout, QBoxLayout, FlowLayout, and BorderLayout.
Definition at line 386 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 QWidgetItem, QGridLayout, QBoxLayout, FlowLayout, QStackedLayout, QWidgetItemV2, and QFormLayout.
Definition at line 420 of file qlayoutitem.cpp.
|
virtual |
Invalidates any cached information in this layout item.
Reimplemented in MyLayout, QToolBarLayout, QMainWindowLayout, QLayout, QGridLayout, QFormLayout, and QBoxLayout.
Definition at line 304 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 LayoutItem, QToolBarLayout, QToolBarItem, QWidgetItem, QSpacerItem, and QLayout.
|
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 314 of file qlayoutitem.cpp.
|
pure virtual |
Implemented in subclasses to return the maximum size of this item.
Implemented in LayoutItem, QDockWidgetItem, QDockWidgetLayout, QWidgetItemV2, QWidgetItem, QSpacerItem, QLayout, QGridLayout, and QBoxLayout.
|
virtual |
Returns the minimum height this widget needs for the given width, w. The default implementation simply returns heightForWidth(w).
Reimplemented in QWidgetItem, QGridLayout, and QBoxLayout.
Definition at line 396 of file qlayoutitem.cpp.
|
pure virtual |
Implemented in subclasses to return the minimum size of this item.
Implemented in LayoutItem, QToolBarLayout, QMainWindowLayout, QDockWidgetItem, QDockWidgetLayout, QStackedLayout, QWidgetItemV2, QWidgetItem, QSpacerItem, QLayout, QGridLayout, QFormLayout, QBoxLayout, CardLayout, FlowLayout, and BorderLayout.
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 192 of file qlayoutitem.cpp.
Implemented in subclasses to set this item's geometry to r.
Implemented in QStackedLayout, QFormLayout, CardLayout, FlowLayout, BorderLayout, LayoutItem, QToolBarLayout, QMainWindowLayout, QDockWidgetLayout, QWidgetItem, QSpacerItem, QLayout, QGridLayout, and QBoxLayout.
|
pure virtual |
Implemented in subclasses to return the preferred size of this item.
Implemented in MyLayout, LayoutItem, QToolBarLayout, QMainWindowLayout, QDockWidgetItem, QDockWidgetLayout, QStackedLayout, QWidgetItemV2, QWidgetItem, QSpacerItem, QGridLayout, QFormLayout, QBoxLayout, CardLayout, FlowLayout, and BorderLayout.
|
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 325 of file qlayoutitem.cpp.
|
virtual |
If this item manages a QWidget, returns that widget. Otherwise, \nullptr is returned.
Reimplemented in QWidgetItem.
Definition at line 363 of file qlayoutitem.cpp.
|
protected |
Definition at line 86 of file qlayoutitem.h.