1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QBoxLayout Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QBoxLayout Class Reference</h1><br clear="all">
<p>
The QBoxLayout class lines up child widgets horizontally or vertically.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qlayout-h.html">qlayout.h</a>></code>
<p>
Inherits <a href="qlayout.html">QLayout</a>.
<p>Inherited by <a href="qhboxlayout.html">QHBoxLayout</a> and <a href="qvboxlayout.html">QVBoxLayout</a>.
<p><a href="qboxlayout-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn">enum<a href="#Direction"><b>Direction</b></a>{LeftToRight, RightToLeft, TopToBottom, BottomToTop, Down=TopToBottom, Up=BottomToTop}</div>
<li><div class="fn"><a href="#cba007"><b>QBoxLayout</b></a>(QWidget*parent, Direction, intborder=0, intspace=-1, constchar*name=0)</div>
<li><div class="fn"><a href="#593f0c"><b>QBoxLayout</b></a>(QLayout*parentLayout, Direction, intspace=-1, constchar*name=0)</div>
<li><div class="fn"><a href="#47abdd"><b>QBoxLayout</b></a>(Direction, intspace=-1, constchar*name=0)</div>
<li><div class="fn"><a href="#2b0688"><b>~QBoxLayout</b></a>()</div>
<li><div class="fn">virtualvoid<a href="#708069"><b>addItem</b></a>(QLayoutItem*)</div>
<li><div class="fn">Direction<a href="#8ef18a"><b>direction</b></a>()const</div>
<li><div class="fn">void<a href="#b27c41"><b>setDirection</b></a>(Direction)</div>
<li><div class="fn">void<a href="#488ad0"><b>addSpacing</b></a>(intsize)</div>
<li><div class="fn">void<a href="#51b0de"><b>addStretch</b></a>(intstretch=0)</div>
<li><div class="fn">void<a href="#219265"><b>addWidget</b></a>(QWidget*, intstretch=0, intalignment=0)</div>
<li><div class="fn">void<a href="#7a3fdc"><b>addLayout</b></a>(QLayout*layout, intstretch=0)</div>
<li><div class="fn">void<a href="#1e1788"><b>addStrut</b></a>(int)</div>
<li><div class="fn">void<a href="#0928b0"><b>insertSpacing</b></a>(intindex, intsize)</div>
<li><div class="fn">void<a href="#bd1e83"><b>insertStretch</b></a>(intindex, intstretch=0)</div>
<li><div class="fn">void<a href="#1244b8"><b>insertWidget</b></a>(intindex, QWidget*widget, intstretch=0, intalignment=0)</div>
<li><div class="fn">void<a href="#86a573"><b>insertLayout</b></a>(intindex, QLayout*layout, intstretch=0)</div>
<li><div class="fn">bool<a href="#388fc5"><b>setStretchFactor</b></a>(QWidget*, intstretch)</div>
<li><div class="fn">bool<a href="#edd3ba"><b>setStretchFactor</b></a>(QLayout*l, intstretch)</div>
<li><div class="fn">virtualQSize<a href="#433998"><b>sizeHint</b></a>()const</div>
<li><div class="fn">virtualQSize<a href="#1a1e69"><b>minimumSize</b></a>()const</div>
<li><div class="fn">virtualQSize<a href="#508fb6"><b>maximumSize</b></a>()const</div>
<li><div class="fn">virtualbool<a href="#1c87fd"><b>hasHeightForWidth</b></a>()const</div>
<li><div class="fn">virtualint<a href="#9786c7"><b>heightForWidth</b></a>(int)const</div>
<li><div class="fn">virtualQSizePolicy::ExpandData<a href="#0b6217"><b>expanding</b></a>()const</div>
<li><div class="fn">virtualvoid<a href="#6d0dbe"><b>invalidate</b></a>()</div>
<li><div class="fn">virtualvoid<a href="#8d9edb"><b>setGeometry</b></a>(constQRect&)</div>
<li><div class="fn">int<a href="#76d5c1"><b>findWidget</b></a>(QWidget*w)</div>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class="fn">void<a href="#389572"><b>insertItem</b></a>(intindex, QLayoutItem*)</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QBoxLayout class lines up child widgets horizontally or vertically.
<p>
QBoxLayout takes the space it gets (from its parent layout or from
the <a href="qlayout.html#db9cb9">mainWidget</a>()), divides it up into a row of boxes and makes each
managed widget fill one box.
<p>If the QBoxLayout is <code>Horizontal,</code> the boxes are beside each other,
with suitable sizes. Each widget (or other box) will get at least
its minimum sizes and at most its maximum size, and any excess space
is shared according to the stretch factors (more about that below).
<p>If the QBoxLayout is <code>Vertical,</code> the boxes are above and below each
other, again with suitable sizes.
<p>The easiest way to create a QBoxLayout is to use one of the
convenience classes <a href="qhboxlayout.html">QHBoxLayout</a> (for <code>Horizontal</code> boxes) or
<a href="qvboxlayout.html">QVBoxLayout</a> (for <code>Vertical</code> boxes). You can also use the QBoxLayout
constructor directly, specifying its direction as <code>LeftToRight, Down, RightToLeft</code> or <code>Up.</code>
<p>If the QBoxLayout is not the top-level layout (ie. is not managing
all of the widget's area and children), you must add it to its
parent layout before you can do anything with it. The normal way to
add a layout is by calling parentLayout-><a href="#7a3fdc">addLayout</a>().
<p>Once you have done that, you can add boxes to the QBoxLayout using
one of four functions: <ul>
<li> <a href="#219265">addWidget</a>() to add a widget to the QBoxLayout and set the
widget's stretch factor. (The stretch factor is along the row of
boxes.)
<li> <a href="#488ad0">addSpacing</a>() to create an empty box; this is one of the
functions you use to create nice and spacious dialogs. See below
for ways to set margins.
<li> <a href="#51b0de">addStretch</a>() to create an empty, stretchable box.
<li> addLayout() to add a box containing another <a href="qlayout.html">QLayout</a> to the row
and set that layout's stretch factor.
<p></ul>
<p>Use <a href="#1244b8">insertWidget</a>(), <a href="#0928b0">insertSpacing</a>(), <a href="#bd1e83">insertStretch</a>() or <a href="#86a573">insertLayout</a>()
to insert a box at a specified position in the layout.
<p>QBoxLayout also includes two margin widths: <ul>
<li> <a href="qlayout.html#cd2c99">setMargin</a>() sets the width of the outer border. This is the width
of the reserved space along each of the QBoxLayout's four sides.
<li> <a href="qlayout.html#03b7a5">setSpacing</a>() sets the inter-box width. This is the width of the
automatically allocated spacing between neighbouring boxes. (You
can use addSpacing() to get more space at a .)
<p></ul>
<p>The outer border width defaults to 0, and the intra-widget width defaults
to the same as the border width for a top-level layout, or to the
same as the parent layout otherwise. Both can be set using
arguments to the constructor.
<p>You will almost always want to use the convenience classes for
QBoxLayout: QVBoxLayout and QHBoxLayout, because of their simpler
constructors.
<p>See also the <a href="layout.html">Layout overview documentation</a>
<p>Examples:
<a href="layout-layout-cpp.html#QBoxLayout">layout/layout.cpp</a>
<a href="popup-popup-cpp.html#QBoxLayout">popup/popup.cpp</a>
<a href="customlayout-main-cpp.html#QBoxLayout">customlayout/main.cpp</a>
<hr><h2>Member Type Documentation</h2>
<h3 class="fn"><a name="Direction">QBoxLayout::Direction</a></h3>
This type is used to determine the direction of
a box layout. The possible values are:
<p><ul>
<li><code>LeftToRight</code> - Horizontal, from left to right
<li><code>RightToLeft</code> - Horizontal, from right to left
<li><code>TopToBottom</code> - Vertical, from top to bottom
<li><code>Down</code> - An alias for <code>TopToBottom</code>
<li><code>BottomToTop</code> - Vertical, from bottom to top
<li><code>Up</code> - An alias for <code>BottomToTop</code>
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="47abdd"></a>QBoxLayout::QBoxLayout(<a href="qboxlayout.html#Direction">Direction</a>d, intspace=-1, constchar*name=0)</h3>
<p>If <em>space</em> is -1, this QBoxLayout will inherit its parent's
<a href="qlayout.html#47a259">spacing</a>(), otherwise <em>space</em> is used.
<p>You have to insert this box into another layout.
<p>Examples:
<a href="layout-layout-cpp.html#QBoxLayout">layout/layout.cpp</a>
<h3 class="fn"><a name="593f0c"></a>QBoxLayout::QBoxLayout(<a href="qlayout.html">QLayout</a>*parentLayout, <a href="qboxlayout.html#Direction">Direction</a>d, intspace=-1, constchar*name=0)</h3>
<p>Constructs a new QBoxLayout with direction <em>d</em> and inserts it into
<em>parentLayout.</em>
<h3 class="fn"><a name="cba007"></a>QBoxLayout::QBoxLayout(<a href="qwidget.html">QWidget</a>*parent, <a href="qboxlayout.html#Direction">Direction</a>d, intborder=0, intspace=-1, constchar*name=0)</h3>
<p>Constructs a new QBoxLayout with direction <em>d</em> and main widget <em>parent. parent</em> may not be 0.
<p><em>border</em> is the number of pixels between the edge of the widget and
the managed children. <em>space</em> is the default number of pixels
between neighbouring children. If <em>space</em> is -1 the value
of <em>border</em> is used.
<p><em>name</em> is the internal object name
<p>See also <a href="#8ef18a">direction</a>().
<h3 class="fn"><a name="2b0688"></a>QBoxLayout::~QBoxLayout()</h3>
<p>Destructs this box.
<h3 class="fn">void<a name="708069"></a>QBoxLayout::addItem(<a href="qlayoutitem.html">QLayoutItem</a>*item) <code>[virtual]</code></h3>
<p>Adds <em>item</em> to the end of this box layout.
<p>Reimplemented from <a href="qlayout.html#3f230a">QLayout.</a>
<h3 class="fn">void<a name="7a3fdc"></a>QBoxLayout::addLayout(<a href="qlayout.html">QLayout</a>*layout, intstretch=0)</h3>
<p>Adds <em>layout</em> to the end of the box, with serial stretch factor <em>stretch.</em>
<p>See also <a href="#86a573">insertLayout</a>(), <a href="qlayout.html#eedc7c">setAutoAdd</a>(), <a href="#219265">addWidget</a>() and <a href="#488ad0">addSpacing</a>().
<h3 class="fn">void<a name="488ad0"></a>QBoxLayout::addSpacing(intsize)</h3>
<p>Adds a non-stretchable space with size <em>size</em> to the end of this
box layout. QBoxLayout gives default border and spacing. This
function adds additional space.
<p>See also <a href="#0928b0">insertSpacing</a>() and <a href="#51b0de">addStretch</a>().
<h3 class="fn">void<a name="51b0de"></a>QBoxLayout::addStretch(intstretch=0)</h3>
<p>Adds a stretchable space with zero minimum size and stretch factor
<em>stretch</em> to the end of this box layout.
<p>See also <a href="#488ad0">addSpacing</a>().
<h3 class="fn">void<a name="1e1788"></a>QBoxLayout::addStrut(intsize)</h3>
<p>Limits the perpendicular dimension of the box (e.g. height if the
box is LeftToRight) to a minimum of <em>size.</em> Other constraints may
increase the limit.
<h3 class="fn">void<a name="219265"></a>QBoxLayout::addWidget(<a href="qwidget.html">QWidget</a>*widget, intstretch=0, intalignment=0)</h3>
<p>Adds <em>widget</em> to the end of this box layout, with a stretch factor
<em>stretch</em> and alignment <em>alignment.</em>
<p>The stretch factor applies only in the <a href="#8ef18a">direction</a> of the QBoxLayout, and is relative to the other boxes and
widgets in this QBoxLayout. Widgets and boxes with higher stretch
factor grow more.
<p>If the stretch factor is 0 and nothing else in the QBoxLayout has a
stretch factor greater than zero, the space is distributed according
to the QWidget:sizePolicy() of each widget that's involved.
<p>Alignment is specified by <em>alignment</em> which is a bitwise OR of
<a href="qt.html#AlignmentFlags">Qt::AlignmentFlags</a> values.
The default alignment is 0, which means
that the widget fills the entire cell.
<p>Note: The alignment parameter is interpreted more aggressively
than in previous versions of Qt. A non-default alignment now
indicates that the widget should not grow to fill the available
space, but should be sized according to <a href="#433998">sizeHint</a>().
<p>See also <a href="#1244b8">insertWidget</a>(), <a href="qlayout.html#eedc7c">setAutoAdd</a>(), <a href="#7a3fdc">addLayout</a>() and <a href="#488ad0">addSpacing</a>().
<p>Examples:
<a href="layout-layout-cpp.html#addWidget">layout/layout.cpp</a>
<a href="popup-popup-cpp.html#addWidget">popup/popup.cpp</a>
<a href="scrollview-scrollview-cpp.html#addWidget">scrollview/scrollview.cpp</a>
<a href="customlayout-main-cpp.html#addWidget">customlayout/main.cpp</a>
<h3 class="fn">QBoxLayout::Direction<a name="8ef18a"></a>QBoxLayout::direction()const</h3>
<p>Returns the (serial) direction of the box. <a href="#219265">addWidget</a>() and <a href="#488ad0">addSpacing</a>()
work in this direction; the stretch stretches in this direction.
<p>The directions are <code>LeftToRight, RightToLeft, TopToBottom</code>
and <code>BottomToTop.</code> For the last two, the shorter aliases <code>Down</code> and
<code>Up</code> are also available.
<p>See also <a href="#219265">addWidget</a>() and <a href="#488ad0">addSpacing</a>().
<h3 class="fn">QSizePolicy::ExpandData<a name="0b6217"></a>QBoxLayout::expanding()const <code>[virtual]</code></h3>
<p>Returns the expansiveness of this layout.
<p>Reimplemented from <a href="qlayoutitem.html#2bf7d6">QLayoutItem.</a>
<h3 class="fn">int<a name="76d5c1"></a>QBoxLayout::findWidget(<a href="qwidget.html">QWidget</a>*w)</h3>
<p>Searches for <em>w</em> in this layout (not including child layouts).
<p>Returns the index of <em>w,</em> or -1 if <em>w</em> is not found.
<h3 class="fn">bool<a name="1c87fd"></a>QBoxLayout::hasHeightForWidth()const <code>[virtual]</code></h3>
<p>Returns whether this layout's preferred height depends on its width.
<p>Reimplemented from <a href="qlayoutitem.html#25207b">QLayoutItem.</a>
<h3 class="fn">int<a name="9786c7"></a>QBoxLayout::heightForWidth(intw)const <code>[virtual]</code></h3>
<p>Returns the layout's preferred height when it is <em>w</em> pixels wide.
<p>Reimplemented from <a href="qlayoutitem.html#740c84">QLayoutItem.</a>
<h3 class="fn">void<a name="389572"></a>QBoxLayout::insertItem(intindex, <a href="qlayoutitem.html">QLayoutItem</a>*item) <code>[protected]</code></h3>
<p>Inserts <em>item</em> in this box layout at index <em>index.</em> If <em>index</em>
is negative, the item is added at the end.<p><b>Warning:</b> does not call QLayout::insertChildLayout() if <em>item</em> is
a <a href="qlayout.html">QLayout</a>.
<p>See also <a href="#708069">addItem</a>() and <a href="#76d5c1">findWidget</a>().
<h3 class="fn">void<a name="86a573"></a>QBoxLayout::insertLayout(intindex, <a href="qlayout.html">QLayout</a>*layout, intstretch=0)</h3>
<p>Inserts <em>layout</em> at index <em>index,</em> with serial stretch
factor <em>stretch.</em> If <em>index</em> is negative, the layout is added at
the end.
<p>See also <a href="qlayout.html#eedc7c">setAutoAdd</a>(), <a href="#1244b8">insertWidget</a>() and <a href="#0928b0">insertSpacing</a>().
<h3 class="fn">void<a name="0928b0"></a>QBoxLayout::insertSpacing(intindex, intsize)</h3>
<p>Inserts a non-stretchable space at index <em>index</em> with size <em>size.</em>
If <em>index</em> is negative, the space is added at the end.
<p>QBoxLayout gives default border and spacing. This function adds
additional space.
<p>See also <a href="#bd1e83">insertStretch</a>().
<h3 class="fn">void<a name="bd1e83"></a>QBoxLayout::insertStretch(intindex, intstretch=0)</h3>
<p>Inserts a stretchable space at index <em>index</em> with zero minimum size
and stretch factor <em>stretch.</em> If <em>index</em> is negative, the space
is added at the end.
<p>See also <a href="#0928b0">insertSpacing</a>().
<h3 class="fn">void<a name="1244b8"></a>QBoxLayout::insertWidget(intindex, <a href="qwidget.html">QWidget</a>*widget, intstretch=0, intalignment=0)</h3>
<p>Inserts <em>widget</em> at index <em>index,</em> with a <em>stretch</em>
factor and <em>alignment.</em> If <em>index</em> is negative, the widget is
added at the end.
<p>The stretch factor applies only in the <a href="#8ef18a">direction</a> of the QBoxLayout, and is relative to the other boxes and
widgets in this QBoxLayout. Widgets and boxes with higher stretch
factor grow more.
<p>If the stretch factor is 0 and nothing else in the QBoxLayout has a
stretch factor greater than zero, the space is distributed according
to the QWidget:sizePolicy() of each widget that's involved.
<p>Alignment is specified by <em>alignment</em> which is a bitwise OR of
<a href="qt.html#AlignmentFlags">Qt::AlignmentFlags</a> values.
The default alignment is 0, which means
that the widget fills the entire cell.
<p>Note: The alignment parameter is interpreted more aggressively
than in previous versions of Qt. A non-default alignment now
indicates that the widget should not grow to fill the available
space, but should be sized according to <a href="#433998">sizeHint</a>().
<p>See also <a href="qlayout.html#eedc7c">setAutoAdd</a>(), <a href="#86a573">insertLayout</a>() and <a href="#0928b0">insertSpacing</a>().
<h3 class="fn">void<a name="6d0dbe"></a>QBoxLayout::invalidate() <code>[virtual]</code></h3>
<p>Resets cached information.
<p>Reimplemented from <a href="qlayoutitem.html#d331d3">QLayoutItem.</a>
<h3 class="fn"><a href="qlayoutiterator.html">QLayoutIterator</a><a name="96881b"></a>QBoxLayout::iterator() <code>[virtual]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qlayoutitem.html#ebfb99">QLayoutItem.</a>
<h3 class="fn"><a href="qsize.html">QSize</a><a name="508fb6"></a>QBoxLayout::maximumSize()const <code>[virtual]</code></h3>
<p>Returns the maximum size needed by this box.
<p>Reimplemented from <a href="qlayoutitem.html#ac28d9">QLayoutItem.</a>
<h3 class="fn"><a href="qsize.html">QSize</a><a name="1a1e69"></a>QBoxLayout::minimumSize()const <code>[virtual]</code></h3>
<p>Returns the minimum size needed by this box.
<p>Reimplemented from <a href="qlayoutitem.html#120a2f">QLayoutItem.</a>
<h3 class="fn">void<a name="b27c41"></a>QBoxLayout::setDirection(<a href="qboxlayout.html#Direction">Direction</a>direction)</h3>
<p>Sets the direction of this layout to <em>direction.</em>
<h3 class="fn">void<a name="8d9edb"></a>QBoxLayout::setGeometry(const<a href="qrect.html">QRect</a>&r) <code>[virtual]</code></h3>
<p>Resizes managed widgets within the rectangle <em>r.</em>
<p>Reimplemented from <a href="qlayoutitem.html#b28121">QLayoutItem.</a>
<h3 class="fn">bool<a name="edd3ba"></a>QBoxLayout::setStretchFactor(<a href="qlayout.html">QLayout</a>*l, intstretch)</h3>
<p>Sets the stretch factor for the layout <em>l</em> to <em>stretch</em> and returns
TRUE, if <em>l</em> is found in this layout (not including child layouts).
<p>Returns FALSE if <em>l</em> is not found.
<h3 class="fn">bool<a name="388fc5"></a>QBoxLayout::setStretchFactor(<a href="qwidget.html">QWidget</a>*w, intstretch)</h3>
<p>Sets the stretch factor for widget <em>w</em> to <em>stretch</em> and returns
TRUE, if <em>w</em> is found in this layout (not including child layouts).
<p>Returns FALSE if <em>w</em> is not found.
<h3 class="fn"><a href="qsize.html">QSize</a><a name="433998"></a>QBoxLayout::sizeHint()const <code>[virtual]</code></h3>
<p>Returns the preferred size of this grid.
<p>Reimplemented from <a href="qlayoutitem.html#e2e8a5">QLayoutItem.</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.1"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2000
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.1</div>
</table></div></address></body></html>
|