.BI "virtual int \fBheightForWidth\fR ( int w ) const"
.br
.ti -1c
.BI "virtual void \fBinvalidate\fR ()"
.br
.ti -1c
.BI "virtual QWidget * \fBwidget\fR ()"
.br
.ti -1c
.BI "virtual QLayoutIterator \fBiterator\fR ()"
.br
.ti -1c
.BI "virtual QLayout * \fBlayout\fR ()"
.br
.ti -1c
.BI "virtual QSpacerItem * \fBspacerItem\fR ()"
.br
.ti -1c
.BI "int \fBalignment\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetAlignment\fR ( int a )"
.br
.in -1c
.SH DESCRIPTION
The QLayoutItem class provides an abstract item that a QLayout manipulates.
.PP
This is used by custom layouts.
.PP
Pure virtual functions are provided to return information about the layout, including, sizeHint(), minimumSize(), maximumSize() and expanding().
.PP
The layout's geometry can be set and retrieved with setGeometry() and geometry(), and its alignment with setAlignment() and alignment().
.PP
isEmpty() returns whether the layout is empty. iterator() returns an iterator for the layout's children. If the concrete item is a QWidget, it can be retrieved using widget(). Similarly for layout() and spacerItem().
.PP
See also QLayout, Widget Appearance and Style, and Layout Management.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QLayoutItem::QLayoutItem ( int alignment = 0 )"
Constructs a layout item with an \fIalignment\fR that is a bitwise OR of the Qt::AlignmentFlags. Not all subclasses support alignment.
Returns TRUE if this layout's preferred height depends on its width; otherwise returns FALSE. The default implementation returns FALSE.
.PP
Reimplement this function in layout managers that support height for width.
.PP
See also heightForWidth() and QWidget::heightForWidth().
.PP
Examples:
.)l customlayout/border.cpp and customlayout/flow.cpp.
.PP
Reimplemented in QGridLayout and QBoxLayout.
.SH "int QLayoutItem::heightForWidth ( int w ) const\fC [virtual]\fR"
Returns the preferred height for this layout item, given the width \fIw\fR.
.PP
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.
.PP
Reimplement this function in layout managers that support height for width. A typical implementation will look like this:
.PP
.nf
.br
int MyLayout::heightForWidth( int w ) const
.br
{
.br
if ( cache_dirty || cached_width != w ) {
.br
// not all C++ compilers support "mutable"
.br
MyLayout *that = (MyLayout*)this;
.br
int h = calculateHeightForWidth( w );
.br
that->cached_hfw = h;
.br
return h;
.br
}
.br
return cached_hfw;
.br
}
.br
.fi
.PP
Caching is strongly recommended; without it layout will take exponential time.