Qt 4.8
|
The QLayoutItem class provides an abstract item that a QLayout manipulates. More...
#include <qlayoutitem.h>
Public Functions | |
Qt::Alignment | alignment () const |
Returns the alignment of this item. More... | |
QSizePolicy::ControlTypes | controlTypes () const |
Returns the control type(s) for the layout item. More... | |
virtual Qt::Orientations | expandingDirections () const =0 |
Returns whether this layout item can make use of more space than sizeHint(). More... | |
virtual QRect | geometry () const =0 |
Returns the rectangle covered by this layout item. More... | |
virtual bool | hasHeightForWidth () const |
Returns true if this layout's preferred height depends on its width; otherwise returns false. More... | |
virtual int | heightForWidth (int) const |
Returns the preferred height for this layout item, given the width w. More... | |
virtual void | invalidate () |
Invalidates any cached information in this layout item. More... | |
virtual bool | isEmpty () const =0 |
Implemented in subclasses to return whether this item is empty, i. More... | |
virtual QLayout * | layout () |
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned. More... | |
virtual QSize | maximumSize () const =0 |
Implemented in subclasses to return the maximum size of this item. More... | |
virtual int | minimumHeightForWidth (int) const |
Returns the minimum height this widget needs for the given width, w. More... | |
virtual QSize | minimumSize () const =0 |
Implemented in subclasses to return the minimum size of this item. More... | |
QLayoutItem (Qt::Alignment alignment=0) | |
Constructs a layout item with an alignment. More... | |
void | setAlignment (Qt::Alignment a) |
Sets the alignment of this item to alignment. More... | |
virtual void | setGeometry (const QRect &)=0 |
Implemented in subclasses to set this item's geometry to r. More... | |
virtual QSize | sizeHint () const =0 |
Implemented in subclasses to return the preferred size of this item. More... | |
virtual QSpacerItem * | spacerItem () |
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned. More... | |
virtual QWidget * | widget () |
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned. More... | |
virtual | ~QLayoutItem () |
Destroys the QLayoutItem. More... | |
Protected Variables | |
Qt::Alignment | align |
The QLayoutItem class provides an abstract item that a QLayout manipulates.
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 Trading Height for Width.
Definition at line 64 of file qlayoutitem.h.
|
inlineexplicit |
Constructs a layout item with an alignment.
Not all subclasses support alignment.
Definition at line 93 of file qlayoutitem.h.
|
virtual |
|
inline |
Returns the alignment of this item.
Definition at line 85 of file qlayoutitem.h.
Referenced by QGridLayout::maximumSize(), QBoxLayout::maximumSize(), setAlignment(), QFormLayout::setFormAlignment(), QBoxLayout::setGeometry(), QGridLayout::setGeometry(), and QFormLayout::setLabelAlignment().
QSizePolicy::ControlTypes QLayoutItem::controlTypes | ( | ) | const |
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.
Definition at line 447 of file qlayoutitem.cpp.
Referenced by controlTypes(), QBoxLayoutPrivate::setupGeom(), and QGridLayoutPrivate::setupSpacings().
|
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 QLayout, QFormLayout, QWidgetItem, QGridLayout, QBoxLayout, QSpacerItem, and QToolBarLayout.
Referenced by QDockAreaLayoutItem::expansive(), QSpacerItem::QSpacerItem(), QWidgetItem::QWidgetItem(), QBoxLayoutPrivate::setupGeom(), updateFormLayoutItem(), and QWizardPrivate::updateLayout().
|
pure virtual |
Returns the rectangle covered by this layout item.
Implemented in QLayout, QWidgetItem, and QSpacerItem.
Referenced by QBoxLayoutPrivate::effectiveMargins(), QGridLayoutPrivate::effectiveMargins(), QSpacerItem::QSpacerItem(), QWidgetItem::QWidgetItem(), QBoxLayoutPrivate::setupGeom(), and QGridLayoutPrivate::setupSpacings().
|
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 QFormLayout, QWidgetItem, QGridLayout, QBoxLayout, and QStackedLayoutHFW.
Definition at line 400 of file qlayoutitem.cpp.
Referenced by QWidgetPrivate::adjustedSize(), QLayout::closestAcceptableSize(), QWidgetPrivate::hasHeightForWidth(), QBoxLayoutItem::hfw(), QBoxLayoutItem::mhfw(), QtWndProc(), QWidgetItem::QWidgetItem(), QBoxLayout::setGeometry(), QWidgetItem::setGeometry(), QBoxLayoutPrivate::setupGeom(), updateFormLayoutItem(), QScrollAreaPrivate::updateScrollBars(), and QMessageBoxPrivate::updateSize().
|
virtual |
Returns the preferred height for this layout item, given the width w.
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 QWidgetItemV2, QFormLayout, QWidgetItem, QGridLayout, QBoxLayout, and QStackedLayoutHFW.
Definition at line 434 of file qlayoutitem.cpp.
Referenced by QBoxLayoutItem::hfw(), QBoxLayoutItem::mhfw(), minimumHeightForWidth(), QWidgetItem::QWidgetItem(), QBoxLayout::setGeometry(), and QWidgetItem::setGeometry().
|
virtual |
Invalidates any cached information in this layout item.
Reimplemented in QMainWindowLayout, QLayout, QFormLayout, QGridLayout, QBoxLayout, and QToolBarLayout.
Definition at line 335 of file qlayoutitem.cpp.
Referenced by QLayout::activateRecursiveHelper().
|
pure virtual |
Implemented in subclasses to return whether this item is empty, i.
e. whether it contains any widgets.
Implemented in QLayout, QWidgetItem, QSpacerItem, QToolBarLayout, and QToolBarItem.
Referenced by QDockAreaLayout::apply(), QWidgetItem::expandingDirections(), QDockAreaLayout::getGrid(), QWidgetItem::hasHeightForWidth(), QWidgetItem::heightForWidth(), QLayout::isEmpty(), QWidgetItem::maximumSize(), QWidgetItem::minimumSize(), QSpacerItem::QSpacerItem(), QWidgetItem::QWidgetItem(), QWidgetItem::setGeometry(), QBoxLayoutPrivate::setupGeom(), QWidgetItem::sizeHint(), QDockAreaLayoutItem::skip(), and QToolBarAreaLayoutItem::skip().
|
virtual |
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
This function provides type-safe casting.
Reimplemented in QLayout.
Definition at line 343 of file qlayoutitem.cpp.
Referenced by QLayout::activateRecursiveHelper(), controlTypes(), QDockWidgetPrivate::endDrag(), QDockWidgetPrivate::init(), QDockWidgetPrivate::initDrag(), QDockWidget::initStyleOption(), QDockWidgetPrivate::mouseDoubleClickEvent(), QDockWidgetPrivate::mouseMoveEvent(), QDockWidgetPrivate::mousePressEvent(), QDockWidgetPrivate::moveEvent(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QWizardPrivate::recreateLayout(), removeWidgetRecursively(), QLayoutPrivate::reparentChildWidgets(), QLayout::setAlignment(), QBoxLayout::setStretchFactor(), QDockWidgetPrivate::setWindowState(), QDockWidgetPrivate::startDrag(), QBoxLayout::takeAt(), QFormLayout::takeAt(), QGridLayoutPrivate::takeAt(), QDockWidgetPrivate::unplug(), QDockWidgetPrivate::updateButtons(), and QMenuBarPrivate::updateCornerWidgetToolBar().
|
pure virtual |
Implemented in subclasses to return the maximum size of this item.
Implemented in QDockWidgetItem, QLayout, QWidgetItemV2, QDockWidgetLayout, QWidgetItem, QSpacerItem, QBoxLayout, and QGridLayout.
Referenced by QDockAreaLayoutItem::maximumSize(), QSpacerItem::QSpacerItem(), QWidgetItem::QWidgetItem(), QBoxLayout::setGeometry(), QWidgetItem::setGeometry(), QBoxLayoutPrivate::setupGeom(), QWidgetItemV2::updateCacheIfNecessary(), and updateFormLayoutItem().
|
virtual |
Returns the minimum height this widget needs for the given width, w.
The default implementation simply returns heightForWidth(w).
Reimplemented in QGridLayout, and QBoxLayout.
Definition at line 410 of file qlayoutitem.cpp.
Referenced by QLayout::closestAcceptableSize().
|
pure virtual |
Implemented in subclasses to return the minimum size of this item.
Implemented in QMainWindowLayout, QDockWidgetItem, QLayout, QWidgetItemV2, QDockWidgetLayout, QFormLayout, QWidgetItem, QSpacerItem, QBoxLayout, QToolBarLayout, QStackedLayout, and QGridLayout.
Referenced by QDockAreaLayout::getGrid(), QBoxLayoutItem::mhfw(), QDockAreaLayoutItem::minimumSize(), QDockAreaLayout::minimumSize(), QSpacerItem::QSpacerItem(), QWidgetItem::QWidgetItem(), QBoxLayout::setGeometry(), QBoxLayoutPrivate::setupGeom(), QWidgetItemV2::updateCacheIfNecessary(), and updateFormLayoutItem().
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 207 of file qlayoutitem.cpp.
Referenced by QToolBarLayout::createItem(), QBoxLayout::insertWidget(), and QLayout::setAlignment().
|
pure virtual |
Implemented in subclasses to set this item's geometry to r.
Implemented in QMainWindowLayout, QLayout, QDockWidgetLayout, QFormLayout, QGridLayout, QWidgetItem, QBoxLayout, QSpacerItem, QStackedLayout, and QToolBarLayout.
Referenced by QSpacerItem::QSpacerItem(), QWidgetItem::QWidgetItem(), and QBoxLayout::setGeometry().
|
pure virtual |
Implemented in subclasses to return the preferred size of this item.
Implemented in QMainWindowLayout, QDockWidgetItem, QWidgetItemV2, QDockWidgetLayout, QFormLayout, QWidgetItem, QSpacerItem, QBoxLayout, QToolBarLayout, QStackedLayout, and QGridLayout.
Referenced by QDockAreaLayout::getGrid(), QBoxLayoutItem::hfw(), QSpacerItem::QSpacerItem(), QWidgetItem::QWidgetItem(), QWidgetItem::setGeometry(), QBoxLayoutPrivate::setupGeom(), QDockAreaLayoutItem::sizeHint(), QDockAreaLayout::sizeHint(), QWidgetItemV2::updateCacheIfNecessary(), and updateFormLayoutItem().
|
virtual |
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned.
This function provides type-safe casting.
Reimplemented in QSpacerItem.
Definition at line 352 of file qlayoutitem.cpp.
Referenced by changeSpacerSize(), QSpacerItem::QSpacerItem(), QBoxLayout::setDirection(), and QComboBoxPrivateContainer::updateTopBottomMargin().
|
virtual |
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
This function provides type-safe casting.
Reimplemented in QWidgetItem.
Definition at line 377 of file qlayoutitem.cpp.
Referenced by QGridLayoutPrivate::addData(), QStackedLayout::addItem(), QStackedLayout::addWidget(), QDockAreaLayoutInfo::apply(), QToolBarAreaLayout::apply(), QDockAreaLayout::apply(), QMainWindowLayoutState::centralWidget(), QMainWindowLayoutState::contains(), controlTypes(), QToolBarLayout::createItem(), QBoxLayoutPrivate::effectiveMargins(), QGridLayoutPrivate::effectiveMargins(), QToolBarAreaLayout::findToolBar(), QToolBarAreaLayoutLine::fitLayout(), fixToolBarOrientation(), QToolBarAreaLayout::getStyleOptionInfo(), QMainWindowLayout::hover(), QBoxLayoutItem::hStretch(), QLayout::indexOf(), QDockAreaLayoutInfo::indexOf(), QToolBarAreaLayout::indexOf(), QDockAreaLayoutInfo::info(), QDockAreaLayoutInfo::insertGap(), QMainWindowLayoutState::insertGap(), QToolBarAreaLayoutInfo::insertItem(), QToolBarAreaLayoutInfo::insertToolBarBreak(), QDialogButtonBoxPrivate::layoutButtons(), QDockAreaLayoutItem::maximumSize(), QStackedLayout::minimumSize(), QDockAreaLayoutItem::minimumSize(), QToolBarAreaLayoutInfo::moveToolBar(), QMainWindowLayout::plug(), QWidgetItem::QWidgetItem(), QToolBarAreaLayoutItem::realSizeHint(), QMainWindowLayoutState::remove(), QToolBarAreaLayoutInfo::removeToolBar(), QToolBarAreaLayoutInfo::removeToolBarBreak(), QLayout::removeWidget(), removeWidgetRecursively(), QLayoutPrivate::reparentChildWidgets(), QMainWindowLayout::revert(), QDockAreaLayoutInfo::saveState(), QAbstractScrollAreaScrollBarContainer::scrollBarLayoutIndex(), QLayout::setAlignment(), QWizardPrivate::setButtonLayout(), QStackedLayout::setCurrentIndex(), QStackedLayout::setGeometry(), QToolBar::setIconSize(), QDeclarativeView::setRootObject(), QStackedLayout::setStackingMode(), QBoxLayout::setStretchFactor(), QBoxLayoutPrivate::setupGeom(), QGridLayoutPrivate::setupSpacings(), QStackedLayout::sizeHint(), QDockAreaLayoutItem::sizeHint(), spacingHelper(), QMainWindowLayout::statusBar(), QDockAreaLayoutInfo::tab(), tabId(), QMainWindow::tabifiedDockWidgets(), QStackedLayout::takeAt(), QDockAreaLayoutInfo::takeAt(), QToolBarAreaLayout::toolBarBreak(), QDockAreaLayoutInfo::updateTabBar(), QBoxLayoutItem::vStretch(), QStackedWidget::widget(), QDockWidgetLayout::widgetForRole(), and QAbstractScrollAreaScrollBarContainer::widgets().
|
protected |
Definition at line 90 of file qlayoutitem.h.
Referenced by QWidgetItem::expandingDirections(), QWidgetItem::maximumSize(), setAlignment(), QWidgetItem::setGeometry(), and QWidgetItemV2::updateCacheIfNecessary().