Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QLayoutItem Class

TheQLayoutItem class provides an abstract item that aQLayout manipulates.More...

Header:#include <QLayoutItem>
Inherited By:

QLayout,QSpacerItem, andQWidgetItem

Public Functions

QLayoutItem(Qt::Alignment alignment = 0)
virtual~QLayoutItem()
Qt::Alignmentalignment() const
QSizePolicy::ControlTypescontrolTypes() const
virtual Qt::OrientationsexpandingDirections() const = 0
virtual QRectgeometry() const = 0
virtual boolhasHeightForWidth() const
virtual intheightForWidth(int w) const
virtual voidinvalidate()
virtual boolisEmpty() const = 0
virtual QLayout *layout()
virtual QSizemaximumSize() const = 0
virtual intminimumHeightForWidth(int w) const
virtual QSizeminimumSize() const = 0
voidsetAlignment(Qt::Alignment alignment)
virtual voidsetGeometry(const QRect & r) = 0
virtual QSizesizeHint() const = 0
virtual QSpacerItem *spacerItem()
virtual QWidget *widget()

Detailed Description

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.

Member Function Documentation

QLayoutItem::QLayoutItem(Qt::Alignment alignment = 0)

Constructs a layout item with analignment. Not all subclasses support alignment.

[virtual]QLayoutItem::~QLayoutItem()

Destroys theQLayoutItem.

Qt::Alignment QLayoutItem::alignment() const

Returns the alignment of this item.

See alsosetAlignment().

QSizePolicy::ControlTypes QLayoutItem::controlTypes() const

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

Returns 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() const

Returns the rectangle covered by this layout item.

See alsosetGeometry().

[virtual]bool QLayoutItem::hasHeightForWidth() const

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.

See alsoheightForWidth() andQWidget::heightForWidth().

[virtual]int QLayoutItem::heightForWidth(int w) const

Returns 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() const

Implemented 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() const

Implemented in subclasses to return the maximum size of this item.

[virtual]int QLayoutItem::minimumHeightForWidth(int w) const

Returns the minimum height this widget needs for the given width,w. The default implementation simply returnsheightForWidth(w).

[pure virtual]QSize QLayoutItem::minimumSize() const

Implemented in subclasses to return the minimum size of this item.

void QLayoutItem::setAlignment(Qt::Alignment alignment)

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

Implemented 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.


[8]ページ先頭

©2009-2025 Movatter.jp