[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qabstractlayout.cpp:56 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QLayoutItem Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QLayoutItem Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QLayoutItem class provides an abstract item that a
|
---|
| 35 | QLayout manipulates.
|
---|
| 36 | <a href="#details">More...</a>
|
---|
| 37 | <p><tt>#include <<a href="qlayout-h.html">qlayout.h</a>></tt>
|
---|
| 38 | <p>Inherited by <a href="qlayout.html">QLayout</a>, <a href="qspaceritem.html">QSpacerItem</a>, and <a href="qwidgetitem.html">QWidgetItem</a>.
|
---|
| 39 | <p><a href="qlayoutitem-members.html">List of all member functions.</a>
|
---|
| 40 | <h2>Public Members</h2>
|
---|
| 41 | <ul>
|
---|
| 42 | <li class=fn><a href="#QLayoutItem"><b>QLayoutItem</b></a> ( int alignment = 0 )</li>
|
---|
| 43 | <li class=fn>virtual <a href="#~QLayoutItem"><b>~QLayoutItem</b></a> ()</li>
|
---|
| 44 | <li class=fn>virtual QSize <a href="#sizeHint"><b>sizeHint</b></a> () const = 0</li>
|
---|
| 45 | <li class=fn>virtual QSize <a href="#minimumSize"><b>minimumSize</b></a> () const = 0</li>
|
---|
| 46 | <li class=fn>virtual QSize <a href="#maximumSize"><b>maximumSize</b></a> () const = 0</li>
|
---|
| 47 | <li class=fn>virtual QSizePolicy::ExpandData <a href="#expanding"><b>expanding</b></a> () const = 0</li>
|
---|
| 48 | <li class=fn>virtual void <a href="#setGeometry"><b>setGeometry</b></a> ( const QRect & r ) = 0</li>
|
---|
| 49 | <li class=fn>virtual QRect <a href="#geometry"><b>geometry</b></a> () const = 0</li>
|
---|
| 50 | <li class=fn>virtual bool <a href="#isEmpty"><b>isEmpty</b></a> () const = 0</li>
|
---|
| 51 | <li class=fn>virtual bool <a href="#hasHeightForWidth"><b>hasHeightForWidth</b></a> () const</li>
|
---|
| 52 | <li class=fn>virtual int <a href="#heightForWidth"><b>heightForWidth</b></a> ( int w ) const</li>
|
---|
| 53 | <li class=fn>virtual void <a href="#invalidate"><b>invalidate</b></a> ()</li>
|
---|
| 54 | <li class=fn>virtual QWidget * <a href="#widget"><b>widget</b></a> ()</li>
|
---|
| 55 | <li class=fn>virtual QLayoutIterator <a href="#iterator"><b>iterator</b></a> ()</li>
|
---|
| 56 | <li class=fn>virtual QLayout * <a href="#layout"><b>layout</b></a> ()</li>
|
---|
| 57 | <li class=fn>virtual QSpacerItem * <a href="#spacerItem"><b>spacerItem</b></a> ()</li>
|
---|
| 58 | <li class=fn>int <a href="#alignment"><b>alignment</b></a> () const</li>
|
---|
| 59 | <li class=fn>virtual void <a href="#setAlignment"><b>setAlignment</b></a> ( int a )</li>
|
---|
| 60 | </ul>
|
---|
| 61 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | The QLayoutItem class provides an abstract item that a
|
---|
| 67 | <a href="qlayout.html">QLayout</a> manipulates.
|
---|
| 68 | <p> This is used by custom layouts.
|
---|
| 69 | <p> Pure virtual functions are provided to return information about
|
---|
| 70 | the layout, including, <a href="#sizeHint">sizeHint</a>(), <a href="#minimumSize">minimumSize</a>(), <a href="#maximumSize">maximumSize</a>()
|
---|
| 71 | and <a href="#expanding">expanding</a>().
|
---|
| 72 | <p> The layout's geometry can be set and retrieved with <a href="#setGeometry">setGeometry</a>()
|
---|
| 73 | and <a href="#geometry">geometry</a>(), and its alignment with <a href="#setAlignment">setAlignment</a>() and
|
---|
| 74 | <a href="#alignment">alignment</a>().
|
---|
| 75 | <p> <a href="#isEmpty">isEmpty</a>() returns whether the layout is empty. <a href="#iterator">iterator</a>() returns
|
---|
| 76 | an iterator for the layout's children. If the concrete item is a
|
---|
| 77 | <a href="qwidget.html">QWidget</a>, it can be retrieved using <a href="#widget">widget</a>(). Similarly for
|
---|
| 78 | <a href="#layout">layout</a>() and <a href="#spacerItem">spacerItem</a>().
|
---|
| 79 | <p> <p>See also <a href="qlayout.html">QLayout</a>, <a href="appearance.html">Widget Appearance and Style</a>, and <a href="geomanagement.html">Layout Management</a>.
|
---|
| 80 |
|
---|
| 81 | <hr><h2>Member Function Documentation</h2>
|
---|
| 82 | <h3 class=fn><a name="QLayoutItem"></a>QLayoutItem::QLayoutItem ( int alignment = 0 )
|
---|
| 83 | </h3>
|
---|
| 84 |
|
---|
| 85 | <p> Constructs a layout item with an <em>alignment</em> that is a bitwise OR
|
---|
| 86 | of the <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>. Not all subclasses support
|
---|
| 87 | alignment.
|
---|
| 88 |
|
---|
| 89 | <h3 class=fn><a name="~QLayoutItem"></a>QLayoutItem::~QLayoutItem ()<tt> [virtual]</tt>
|
---|
| 90 | </h3>
|
---|
| 91 | Destroys the QLayoutItem.
|
---|
| 92 |
|
---|
| 93 | <h3 class=fn>int <a name="alignment"></a>QLayoutItem::alignment () const
|
---|
| 94 | </h3>
|
---|
| 95 |
|
---|
| 96 | <p> Returns the alignment of this item.
|
---|
| 97 |
|
---|
| 98 | <h3 class=fn><a href="qsizepolicy.html#ExpandData-enum">QSizePolicy::ExpandData</a> <a name="expanding"></a>QLayoutItem::expanding () const<tt> [pure virtual]</tt>
|
---|
| 99 | </h3>
|
---|
| 100 |
|
---|
| 101 | <p> Implemented in subclasses to return the direction(s) this item
|
---|
| 102 | "wants" to expand in (if any).
|
---|
| 103 |
|
---|
| 104 | <p>Reimplemented in <a href="qlayout.html#expanding">QLayout</a>, <a href="qspaceritem.html#expanding">QSpacerItem</a>, and <a href="qwidgetitem.html#expanding">QWidgetItem</a>.
|
---|
| 105 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="geometry"></a>QLayoutItem::geometry () const<tt> [pure virtual]</tt>
|
---|
| 106 | </h3>
|
---|
| 107 |
|
---|
| 108 | <p> Returns the rectangle covered by this layout item.
|
---|
| 109 |
|
---|
| 110 | <p>Example: <a href="customlayout-example.html#x1495">customlayout/border.cpp</a>.
|
---|
| 111 | <h3 class=fn>bool <a name="hasHeightForWidth"></a>QLayoutItem::hasHeightForWidth () const<tt> [virtual]</tt>
|
---|
| 112 | </h3>
|
---|
| 113 | Returns TRUE if this layout's preferred height depends on its
|
---|
| 114 | width; otherwise returns FALSE. The default implementation returns
|
---|
| 115 | FALSE.
|
---|
| 116 | <p> Reimplement this function in layout managers that support height
|
---|
| 117 | for width.
|
---|
| 118 | <p> <p>See also <a href="#heightForWidth">heightForWidth</a>() and <a href="qwidget.html#heightForWidth">QWidget::heightForWidth</a>().
|
---|
| 119 |
|
---|
| 120 | <p>Examples: <a href="customlayout-example.html#x1496">customlayout/border.cpp</a> and <a href="customlayout-example.html#x1472">customlayout/flow.cpp</a>.
|
---|
| 121 | <p>Reimplemented in <a href="qgridlayout.html#hasHeightForWidth">QGridLayout</a> and <a href="qboxlayout.html#hasHeightForWidth">QBoxLayout</a>.
|
---|
| 122 | <h3 class=fn>int <a name="heightForWidth"></a>QLayoutItem::heightForWidth ( int w ) const<tt> [virtual]</tt>
|
---|
| 123 | </h3>
|
---|
| 124 | Returns the preferred height for this layout item, given the width
|
---|
| 125 | <em>w</em>.
|
---|
| 126 | <p> The default implementation returns -1, indicating that the
|
---|
| 127 | preferred height is independent of the width of the item. Using
|
---|
| 128 | the function <a href="#hasHeightForWidth">hasHeightForWidth</a>() will typically be much faster
|
---|
| 129 | than calling this function and testing for -1.
|
---|
| 130 | <p> Reimplement this function in layout managers that support height
|
---|
| 131 | for width. A typical implementation will look like this:
|
---|
| 132 | <pre>
|
---|
| 133 | int MyLayout::heightForWidth( int w ) const
|
---|
| 134 | {
|
---|
| 135 | if ( cache_dirty || cached_width != w ) {
|
---|
| 136 | // not all C++ compilers support "mutable"
|
---|
| 137 | MyLayout *that = (MyLayout*)this;
|
---|
| 138 | int h = calculateHeightForWidth( w );
|
---|
| 139 | that->cached_hfw = h;
|
---|
| 140 | return h;
|
---|
| 141 | }
|
---|
| 142 | return cached_hfw;
|
---|
| 143 | }
|
---|
| 144 | </pre>
|
---|
| 145 |
|
---|
| 146 | <p> Caching is strongly recommended; without it layout will take
|
---|
| 147 | exponential time.
|
---|
| 148 | <p> <p>See also <a href="#hasHeightForWidth">hasHeightForWidth</a>().
|
---|
| 149 |
|
---|
| 150 | <p>Example: <a href="customlayout-example.html#x1473">customlayout/flow.cpp</a>.
|
---|
| 151 | <p>Reimplemented in <a href="qgridlayout.html#heightForWidth">QGridLayout</a> and <a href="qboxlayout.html#heightForWidth">QBoxLayout</a>.
|
---|
| 152 | <h3 class=fn>void <a name="invalidate"></a>QLayoutItem::invalidate ()<tt> [virtual]</tt>
|
---|
| 153 | </h3>
|
---|
| 154 | Invalidates any cached information in this layout item.
|
---|
| 155 |
|
---|
| 156 | <p>Reimplemented in <a href="qlayout.html#invalidate">QLayout</a>.
|
---|
| 157 | <h3 class=fn>bool <a name="isEmpty"></a>QLayoutItem::isEmpty () const<tt> [pure virtual]</tt>
|
---|
| 158 | </h3>
|
---|
| 159 |
|
---|
| 160 | <p> Implemented in subclasses to return whether this item is empty,
|
---|
| 161 | i.e. whether it contains any widgets.
|
---|
| 162 |
|
---|
| 163 | <p>Reimplemented in <a href="qlayout.html#isEmpty">QLayout</a>, <a href="qspaceritem.html#isEmpty">QSpacerItem</a>, and <a href="qwidgetitem.html#isEmpty">QWidgetItem</a>.
|
---|
| 164 | <h3 class=fn><a href="qlayoutiterator.html">QLayoutIterator</a> <a name="iterator"></a>QLayoutItem::iterator ()<tt> [virtual]</tt>
|
---|
| 165 | </h3>
|
---|
| 166 | Returns an iterator over this item's QLayoutItem children. The
|
---|
| 167 | default implementation returns an empty iterator.
|
---|
| 168 | <p> Reimplement this function in subclasses that can have children.
|
---|
| 169 |
|
---|
| 170 | <p>Reimplemented in <a href="qlayout.html#iterator">QLayout</a>.
|
---|
| 171 | <h3 class=fn><a href="qlayout.html">QLayout</a> * <a name="layout"></a>QLayoutItem::layout ()<tt> [virtual]</tt>
|
---|
| 172 | </h3>
|
---|
| 173 | If this item is a <a href="qlayout.html">QLayout</a>, it is returned as a QLayout; otherwise
|
---|
| 174 | 0 is returned. This function provides type-safe casting.
|
---|
| 175 |
|
---|
| 176 | <h3 class=fn><a href="qsize.html">QSize</a> <a name="maximumSize"></a>QLayoutItem::maximumSize () const<tt> [pure virtual]</tt>
|
---|
| 177 | </h3>
|
---|
| 178 |
|
---|
| 179 | <p> Implemented in subclasses to return the maximum size of this item.
|
---|
| 180 |
|
---|
| 181 | <p>Reimplemented in <a href="qlayout.html#maximumSize">QLayout</a>, <a href="qspaceritem.html#maximumSize">QSpacerItem</a>, and <a href="qwidgetitem.html#maximumSize">QWidgetItem</a>.
|
---|
| 182 | <h3 class=fn><a href="qsize.html">QSize</a> <a name="minimumSize"></a>QLayoutItem::minimumSize () const<tt> [pure virtual]</tt>
|
---|
| 183 | </h3>
|
---|
| 184 |
|
---|
| 185 | <p> Implemented in subclasses to return the minimum size of this item.
|
---|
| 186 |
|
---|
| 187 | <p>Examples: <a href="customlayout-example.html#x1497">customlayout/border.cpp</a>, <a href="customlayout-example.html#x1515">customlayout/card.cpp</a>, and <a href="customlayout-example.html#x1474">customlayout/flow.cpp</a>.
|
---|
| 188 | <p>Reimplemented in <a href="qlayout.html#minimumSize">QLayout</a>, <a href="qspaceritem.html#minimumSize">QSpacerItem</a>, and <a href="qwidgetitem.html#minimumSize">QWidgetItem</a>.
|
---|
| 189 | <h3 class=fn>void <a name="setAlignment"></a>QLayoutItem::setAlignment ( int a )<tt> [virtual]</tt>
|
---|
| 190 | </h3>
|
---|
| 191 | Sets the alignment of this item to <em>a</em>, which is a bitwise OR of
|
---|
| 192 | the <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>. Not all subclasses support alignment.
|
---|
| 193 |
|
---|
| 194 | <p>Example: <a href="tutorial2-09.html#x2644">chart/optionsform.cpp</a>.
|
---|
| 195 | <h3 class=fn>void <a name="setGeometry"></a>QLayoutItem::setGeometry ( const <a href="qrect.html">QRect</a> & r )<tt> [pure virtual]</tt>
|
---|
| 196 | </h3>
|
---|
| 197 |
|
---|
| 198 | <p> Implemented in subclasses to set this item's geometry to <em>r</em>.
|
---|
| 199 |
|
---|
| 200 | <p>Examples: <a href="customlayout-example.html#x1498">customlayout/border.cpp</a>, <a href="customlayout-example.html#x1516">customlayout/card.cpp</a>, and <a href="customlayout-example.html#x1475">customlayout/flow.cpp</a>.
|
---|
| 201 | <p>Reimplemented in <a href="qlayout.html#setGeometry">QLayout</a>, <a href="qspaceritem.html#setGeometry">QSpacerItem</a>, and <a href="qwidgetitem.html#setGeometry">QWidgetItem</a>.
|
---|
| 202 | <h3 class=fn><a href="qsize.html">QSize</a> <a name="sizeHint"></a>QLayoutItem::sizeHint () const<tt> [pure virtual]</tt>
|
---|
| 203 | </h3>
|
---|
| 204 |
|
---|
| 205 | <p> Implemented in subclasses to return the preferred size of this item.
|
---|
| 206 |
|
---|
| 207 | <p>Examples: <a href="customlayout-example.html#x1499">customlayout/border.cpp</a>, <a href="customlayout-example.html#x1517">customlayout/card.cpp</a>, and <a href="customlayout-example.html#x1476">customlayout/flow.cpp</a>.
|
---|
| 208 | <p>Reimplemented in <a href="qspaceritem.html#sizeHint">QSpacerItem</a>, <a href="qwidgetitem.html#sizeHint">QWidgetItem</a>, <a href="qgridlayout.html#sizeHint">QGridLayout</a>, and <a href="qboxlayout.html#sizeHint">QBoxLayout</a>.
|
---|
| 209 | <h3 class=fn><a href="qspaceritem.html">QSpacerItem</a> * <a name="spacerItem"></a>QLayoutItem::spacerItem ()<tt> [virtual]</tt>
|
---|
| 210 | </h3>
|
---|
| 211 | If this item is a <a href="qspaceritem.html">QSpacerItem</a>, it is returned as a QSpacerItem;
|
---|
| 212 | otherwise 0 is returned. This function provides type-safe casting.
|
---|
| 213 |
|
---|
| 214 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="widget"></a>QLayoutItem::widget ()<tt> [virtual]</tt>
|
---|
| 215 | </h3>
|
---|
| 216 | If this item is a <a href="qwidget.html">QWidget</a>, it is returned as a QWidget; otherwise
|
---|
| 217 | 0 is returned. This function provides type-safe casting.
|
---|
| 218 |
|
---|
| 219 | <p>Reimplemented in <a href="qwidgetitem.html#widget">QWidgetItem</a>.
|
---|
| 220 | <!-- eof -->
|
---|
| 221 | <hr><p>
|
---|
| 222 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 223 | Copyright © 1995-2007
|
---|
| 224 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 225 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 226 | <td>Copyright © 2007
|
---|
| 227 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 228 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 229 | </table></div></address></body>
|
---|
| 230 | </html>
|
---|