1QBoxLayout(3qt)                                                QBoxLayout(3qt)
2
3
4

NAME

6       QBoxLayout - Lines up child widgets horizontally or vertically
7

SYNOPSIS

9       #include <qlayout.h>
10
11       Inherits QLayout.
12
13       Inherited by QHBoxLayout and QVBoxLayout.
14
15   Public Members
16       enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
17           Down = TopToBottom, Up = BottomToTop }
18       QBoxLayout ( QWidget * parent, Direction d, int margin = 0, int spacing
19           = -1, const char * name = 0 )
20       QBoxLayout ( QLayout * parentLayout, Direction d, int spacing = -1,
21           const char * name = 0 )
22       QBoxLayout ( Direction d, int spacing = -1, const char * name = 0 )
23       ~QBoxLayout ()
24       virtual void addItem ( QLayoutItem * item )
25       Direction direction () const
26       void setDirection ( Direction direction )
27       void addSpacing ( int size )
28       void addStretch ( int stretch = 0 )
29       void addWidget ( QWidget * widget, int stretch = 0, int alignment = 0 )
30       void addLayout ( QLayout * layout, int stretch = 0 )
31       void addStrut ( int size )
32       void insertSpacing ( int index, int size )
33       void insertStretch ( int index, int stretch = 0 )
34       void insertWidget ( int index, QWidget * widget, int stretch = 0, int
35           alignment = 0 )
36       void insertLayout ( int index, QLayout * layout, int stretch = 0 )
37       bool setStretchFactor ( QWidget * w, int stretch )
38       bool setStretchFactor ( QLayout * l, int stretch )
39       virtual QSize sizeHint () const
40       virtual QSize minimumSize () const
41       virtual QSize maximumSize () const
42       virtual bool hasHeightForWidth () const
43       virtual int heightForWidth ( int w ) const
44       virtual QSizePolicy::ExpandData expanding () const
45       virtual void invalidate ()
46       virtual void setGeometry ( const QRect & r )
47       int findWidget ( QWidget * w )
48
49   Protected Members
50       void insertItem ( int index, QLayoutItem * item )
51

DESCRIPTION

53       The QBoxLayout class lines up child widgets horizontally or vertically.
54
55       QBoxLayout takes the space it gets (from its parent layout or from the
56       mainWidget()), divides it up into a row of boxes, and makes each
57       managed widget fill one box.
58
59       <center>
60                                   [Image Omitted]
61
62       </center>
63
64       If the QBoxLayout's orientation is Horizontal the boxes are placed in a
65       row, with suitable sizes. Each widget (or other box) will get at least
66       its minimum size and at most its maximum size. Any excess space is
67       shared according to the stretch factors (more about that below).
68
69       <center>
70                                   [Image Omitted]
71
72       </center>
73
74       If the QBoxLayout's orientation is Vertical, the boxes are placed in a
75       column, again with suitable sizes.
76
77       The easiest way to create a QBoxLayout is to use one of the convenience
78       classes, e.g. QHBoxLayout (for Horizontal boxes) or QVBoxLayout (for
79       Vertical boxes). You can also use the QBoxLayout constructor directly,
80       specifying its direction as LeftToRight, Down, RightToLeft or Up.
81
82       If the QBoxLayout is not the top-level layout (i.e. it is not managing
83       all of the widget's area and children), you must add it to its parent
84       layout before you can do anything with it. The normal way to add a
85       layout is by calling parentLayout->addLayout().
86
87       Once you have done this, you can add boxes to the QBoxLayout using one
88       of four functions:
89
90       addWidget() to add a widget to the QBoxLayout and set the widget's
91       stretch factor. (The stretch factor is along the row of boxes.)
92
93       addSpacing() to create an empty box; this is one of the functions you
94       use to create nice and spacious dialogs. See below for ways to set
95       margins.
96
97       addStretch() to create an empty, stretchable box.
98
99       addLayout() to add a box containing another QLayout to the row and set
100       that layout's stretch factor.
101
102       Use insertWidget(), insertSpacing(), insertStretch() or insertLayout()
103       to insert a box at a specified position in the layout.
104
105       QBoxLayout also includes two margin widths:
106
107       setMargin() sets the width of the outer border. This is the width of
108       the reserved space along each of the QBoxLayout's four sides.
109
110       setSpacing() sets the width between neighboring boxes. (You can use
111       addSpacing() to get more space at a particular spot.)
112
113       The margin defaults to 0. The spacing defaults to the same as the
114       margin width for a top-level layout, or to the same as the parent
115       layout. Both are parameters to the constructor.
116
117       To remove a widget from a layout, call remove(). Calling
118       QWidget::hide() on a widget also effectively removes the widget from
119       the layout until QWidget::show() is called.
120
121       You will almost always want to use QVBoxLayout and QHBoxLayout rather
122       than QBoxLayout because of their convenient constructors.
123
124       See also QGrid, Layout Overview, Widget Appearance and Style, and
125       Layout Management.
126
127   Member Type Documentation

QBoxLayout::Direction

129       This type is used to determine the direction of a box layout.
130
131       QBoxLayout::LeftToRight - Horizontal, from left to right
132
133       QBoxLayout::RightToLeft - Horizontal, from right to left
134
135       QBoxLayout::TopToBottom - Vertical, from top to bottom
136
137       QBoxLayout::Down - The same as TopToBottom
138
139       QBoxLayout::BottomToTop - Vertical, from bottom to top
140
141       QBoxLayout::Up - The same as BottomToTop
142

MEMBER FUNCTION DOCUMENTATION

QBoxLayout::QBoxLayout ( QWidget * parent, Direction d, int margin = 0, int

145       spacing = -1, const char * name = 0 )
146       Constructs a new QBoxLayout with direction d and main widget parent.
147       parent may not be 0.
148
149       The margin is the number of pixels between the edge of the widget and
150       its managed children. The spacing is the default number of pixels
151       between neighboring children. If spacing is -1 the value of margin is
152       used for spacing.
153
154       name is the internal object name.
155
156       See also direction().
157

QBoxLayout::QBoxLayout ( QLayout * parentLayout, Direction d, int spacing =

159       -1, const char * name = 0 )
160       Constructs a new QBoxLayout called name, with direction d, and inserts
161       it into parentLayout.
162
163       The spacing is the default number of pixels between neighboring
164       children. If spacing is -1, the layout will inherit its parent's
165       spacing().
166

QBoxLayout::QBoxLayout ( Direction d, int spacing = -1, const char * name = 0

168       )
169       Constructs a new QBoxLayout called name, with direction d.
170
171       If spacing is -1, the layout will inherit its parent's spacing();
172       otherwise spacing is used.
173
174       You must insert this box into another layout.
175

QBoxLayout::~QBoxLayout ()

177       Destroys this box layout.
178
179       The layout's widgets aren't destroyed.
180

void QBoxLayout::addItem ( QLayoutItem * item ) [virtual]

182       Adds item to the end of this box layout.
183
184       Examples:
185
186       Reimplemented from QLayout.
187

void QBoxLayout::addLayout ( QLayout * layout, int stretch = 0 )

189       Adds layout to the end of the box, with serial stretch factor stretch.
190
191       When a layout is constructed with another layout as its parent, you
192       don't need to call addLayout(); the child layout is automatically added
193       to the parent layout as it is constructed.
194
195       See also insertLayout(), setAutoAdd(), addWidget(), and addSpacing().
196
197       Examples:
198

void QBoxLayout::addSpacing ( int size )

200       Adds a non-stretchable space with size size to the end of this box
201       layout. QBoxLayout provides default margin and spacing. This function
202       adds additional space.
203
204       See also insertSpacing() and addStretch().
205
206       Example: listbox/listbox.cpp.
207

void QBoxLayout::addStretch ( int stretch = 0 )

209       Adds a stretchable space with zero minimum size and stretch factor
210       stretch to the end of this box layout.
211
212       See also addSpacing().
213
214       Examples:
215

void QBoxLayout::addStrut ( int size )

217       Limits the perpendicular dimension of the box (e.g. height if the box
218       is LeftToRight) to a minimum of size. Other constraints may increase
219       the limit.
220

void QBoxLayout::addWidget ( QWidget * widget, int stretch = 0, int alignment

222       = 0 )
223       Adds widget to the end of this box layout, with a stretch factor of
224       stretch and alignment alignment.
225
226       The stretch factor applies only in the direction of the QBoxLayout, and
227       is relative to the other boxes and widgets in this QBoxLayout. Widgets
228       and boxes with higher stretch factors grow more.
229
230       If the stretch factor is 0 and nothing else in the QBoxLayout has a
231       stretch factor greater than zero, the space is distributed according to
232       the QWidget:sizePolicy() of each widget that's involved.
233
234       Alignment is specified by alignment which is a bitwise OR of
235       Qt::AlignmentFlags values. The default alignment is 0, which means that
236       the widget fills the entire cell.
237
238       From Qt 3.0, the alignment parameter is interpreted more aggressively
239       than in previous versions of Qt. A non-default alignment now indicates
240       that the widget should not grow to fill the available space, but should
241       be sized according to sizeHint().
242
243       See also insertWidget(), setAutoAdd(), addLayout(), and addSpacing().
244
245       Examples:
246

Direction QBoxLayout::direction () const

248       Returns the direction of the box. addWidget() and addSpacing() work in
249       this direction; the stretch stretches in this direction.
250
251       See also QBoxLayout::Direction, addWidget(), and addSpacing().
252

QSizePolicy::ExpandData QBoxLayout::expanding () const [virtual]

254       Returns whether this layout can make use of more space than sizeHint().
255       A value of Vertical or Horizontal means that it wants to grow in only
256       one dimension, whereas BothDirections means that it wants to grow in
257       both dimensions.
258
259       Reimplemented from QLayout.
260

int QBoxLayout::findWidget ( QWidget * w )

262       Searches for widget w in this layout (not including child layouts).
263
264       Returns the index of w, or -1 if w is not found.
265

bool QBoxLayout::hasHeightForWidth () const [virtual]

267       Returns TRUE if this layout's preferred height depends on its width;
268       otherwise returns FALSE.
269
270       Reimplemented from QLayoutItem.
271

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

273       Returns the layout's preferred height when it is w pixels wide.
274
275       Reimplemented from QLayoutItem.
276

void QBoxLayout::insertItem ( int index, QLayoutItem * item ) [protected]

278       Inserts item into this box layout at position index. If index is
279       negative, the item is added at the end.
280
281       Warning: Does not call QLayout::insertChildLayout() if item is a
282       QLayout.
283
284       See also addItem() and findWidget().
285

void QBoxLayout::insertLayout ( int index, QLayout * layout, int stretch = 0 )

287
288       Inserts layout at position index, with stretch factor stretch. If index
289       is negative, the layout is added at the end.
290
291       layout becomes a child of the box layout.
292
293       See also setAutoAdd(), insertWidget(), and insertSpacing().
294

void QBoxLayout::insertSpacing ( int index, int size )

296       Inserts a non-stretchable space at position index, with size size. If
297       index is negative the space is added at the end.
298
299       The box layout has default margin and spacing. This function adds
300       additional space.
301
302       See also insertStretch().
303

void QBoxLayout::insertStretch ( int index, int stretch = 0 )

305       Inserts a stretchable space at position index, with zero minimum size
306       and stretch factor stretch. If index is negative the space is added at
307       the end.
308
309       See also insertSpacing().
310

void QBoxLayout::insertWidget ( int index, QWidget * widget, int stretch = 0,

312       int alignment = 0 )
313       Inserts widget at position index, with stretch factor stretch and
314       alignment alignment. If index is negative, the widget is added at the
315       end.
316
317       The stretch factor applies only in the direction of the QBoxLayout, and
318       is relative to the other boxes and widgets in this QBoxLayout. Widgets
319       and boxes with higher stretch factors grow more.
320
321       If the stretch factor is 0 and nothing else in the QBoxLayout has a
322       stretch factor greater than zero, the space is distributed according to
323       the QWidget:sizePolicy() of each widget that's involved.
324
325       Alignment is specified by alignment, which is a bitwise OR of
326       Qt::AlignmentFlags values. The default alignment is 0, which means that
327       the widget fills the entire cell.
328
329       From Qt 3.0, the alignment parameter is interpreted more aggressively
330       than in previous versions of Qt. A non-default alignment now indicates
331       that the widget should not grow to fill the available space, but should
332       be sized according to sizeHint().
333
334       See also setAutoAdd(), insertLayout(), and insertSpacing().
335

void QBoxLayout::invalidate () [virtual]

337       Resets cached information.
338
339       Reimplemented from QLayout.
340

QSize QBoxLayout::maximumSize () const [virtual]

342       Returns the maximum size needed by this box layout.
343
344       Reimplemented from QLayout.
345

QSize QBoxLayout::minimumSize () const [virtual]

347       Returns the minimum size needed by this box layout.
348
349       Reimplemented from QLayout.
350

void QBoxLayout::setDirection ( Direction direction )

352       Sets the direction of this layout to direction.
353

void QBoxLayout::setGeometry ( const QRect & r ) [virtual]

355       Resizes managed widgets within the rectangle r.
356
357       Reimplemented from QLayout.
358

bool QBoxLayout::setStretchFactor ( QWidget * w, int stretch )

360       Sets the stretch factor for widget w to stretch and returns TRUE if w
361       is found in this layout (not including child layouts); otherwise
362       returns FALSE.
363

bool QBoxLayout::setStretchFactor ( QLayout * l, int stretch )

365       This is an overloaded member function, provided for convenience. It
366       behaves essentially like the above function.
367
368       Sets the stretch factor for the layout l to stretch and returns TRUE if
369       l is found in this layout (not including child layouts); otherwise
370       returns FALSE.
371

QSize QBoxLayout::sizeHint () const [virtual]

373       Returns the preferred size of this box layout.
374
375       Reimplemented from QLayoutItem.
376
377

SEE ALSO

379       http://doc.trolltech.com/qboxlayout.html
380       http://www.trolltech.com/faq/tech.html
381
383       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
384       license file included in the distribution for a complete license
385       statement.
386

AUTHOR

388       Generated automatically from the source code.
389

BUGS

391       If you find a bug in Qt, please report it as described in
392       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
393       help you. Thank you.
394
395       The definitive Qt documentation is provided in HTML format; it is
396       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
397       web browser. This man page is provided as a convenience for those users
398       who prefer man pages, although this format is not officially supported
399       by Trolltech.
400
401       If you find errors in this manual page, please report them to qt-
402       bugs@trolltech.com.  Please include the name of the manual page
403       (qboxlayout.3qt) and the Qt version (3.3.8).
404
405
406
407Trolltech AS                    2 February 2007                QBoxLayout(3qt)
Impressum