
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQLayoutItem class provides an abstract item that aQLayout manipulates.More...
| Header: | #include <QLayoutItem> |
| Inherited By: |
| QLayoutItem(Qt::Alignment alignment = 0) | |
| virtual | ~QLayoutItem() |
| Qt::Alignment | alignment() const |
| QSizePolicy::ControlTypes | controlTypes() const |
| virtual Qt::Orientations | expandingDirections() const = 0 |
| virtual QRect | geometry() const = 0 |
| virtual bool | hasHeightForWidth() const |
| virtual int | heightForWidth(int w) const |
| virtual void | invalidate() |
| virtual bool | isEmpty() const = 0 |
| virtual QLayout * | layout() |
| virtual QSize | maximumSize() const = 0 |
| virtual int | minimumHeightForWidth(int w) const |
| virtual QSize | minimumSize() const = 0 |
| void | setAlignment(Qt::Alignment alignment) |
| virtual void | setGeometry(const QRect & r) = 0 |
| virtual QSize | sizeHint() const = 0 |
| virtual QSpacerItem * | spacerItem() |
| virtual QWidget * | widget() |
TheQLayoutItem class provides an abstract item that aQLayout 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 withsetGeometry() andgeometry(), and its alignment withsetAlignment() andalignment().
isEmpty() returns whether the layout item is empty. If the concrete item is aQWidget, it can be retrieved usingwidget(). Similarly forlayout() andspacerItem().
Some layouts have width and height interdependencies. These can be expressed usinghasHeightForWidth(),heightForWidth(), andminimumHeightForWidth(). For more explanation see theQt Quarterly articleTrading Height for Width.
See alsoQLayout.
Constructs a layout item with analignment. Not all subclasses support alignment.
[virtual]QLayoutItem::~QLayoutItem()Destroys theQLayoutItem.
Returns the alignment of this item.
See alsosetAlignment().
Returns the control type(s) for the layout item. For aQWidgetItem, the control type comes from the widget's size policy; for aQLayoutItem, the control types is derived from the layout's contents.
See alsoQSizePolicy::controlType().
[pure virtual]Qt::Orientations QLayoutItem::expandingDirections() constReturns whether this layout item can make use of more space thansizeHint(). A value ofQt::Vertical orQt::Horizontal means that it wants to grow in only one dimension, whereasQt::Vertical |Qt::Horizontal means that it wants to grow in both dimensions.
[pure virtual]QRect QLayoutItem::geometry() constReturns the rectangle covered by this layout item.
See alsosetGeometry().
[virtual]bool QLayoutItem::hasHeightForWidth() constReturns 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.
See alsoheightForWidth() andQWidget::heightForWidth().
[virtual]int QLayoutItem::heightForWidth(int w) constReturns the preferred height for this layout item, given the widthw.
The default implementation returns -1, indicating that the preferred height is independent of the width of the item. Using the functionhasHeightForWidth() 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:
int MyLayout::heightForWidth(int w)const{if (cache_dirty|| cached_width!= w) {// not all C++ compilers support "mutable" MyLayout*that= (MyLayout*)this;int h= calculateHeightForWidth(w); that->cached_hfw= h;return h; }return cached_hfw;}
Caching is strongly recommended; without it layout will take exponential time.
See alsohasHeightForWidth().
[virtual]void QLayoutItem::invalidate()Invalidates any cached information in this layout item.
[pure virtual]bool QLayoutItem::isEmpty() constImplemented in subclasses to return whether this item is empty, i.e. whether it contains any widgets.
[virtual]QLayout * QLayoutItem::layout()If this item is aQLayout, it is returned as aQLayout; otherwise 0 is returned. This function provides type-safe casting.
[pure virtual]QSize QLayoutItem::maximumSize() constImplemented in subclasses to return the maximum size of this item.
[virtual]int QLayoutItem::minimumHeightForWidth(int w) constReturns the minimum height this widget needs for the given width,w. The default implementation simply returnsheightForWidth(w).
[pure virtual]QSize QLayoutItem::minimumSize() constImplemented in subclasses to return the minimum size of this item.
Sets the alignment of this item toalignment.
Note: Item alignment is only supported byQLayoutItem subclasses where it would have a visual effect. Except forQSpacerItem, which provides blank space for layouts, all public Qt classes that inheritQLayoutItem support item alignment.
See alsoalignment().
[pure virtual]void QLayoutItem::setGeometry(constQRect & r)Implemented in subclasses to set this item's geometry tor.
See alsogeometry().
[pure virtual]QSize QLayoutItem::sizeHint() constImplemented in subclasses to return the preferred size of this item.
[virtual]QSpacerItem * QLayoutItem::spacerItem()If this item is aQSpacerItem, it is returned as aQSpacerItem; otherwise 0 is returned. This function provides type-safe casting.
[virtual]QWidget * QLayoutItem::widget()If this item is aQWidget, it is returned as aQWidget; otherwise 0 is returned. This function provides type-safe casting.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.