The QBoxLayout class lines up child widgets horizontally or vertically. More...
#include <qlayout.h>
Inherits QLayout.
Inherited by QHBoxLayout and QVBoxLayout.
QBoxLayout takes the space it gets (from its parent layout or from the mainWindget()), divides it up into a row of boxes and makes each managed widget fill one box.
If the QBoxLayout is Horizontal,
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).
If the QBoxLayout is Vertical,
the boxes are above and below each
other, again with suitable sizes.
The easiest way to create a QBoxLayout is to use one of the
convenience classes QHBoxLayout (for Horizontal
boxes) or
QVBoxLayout (for Vertical
boxes). You can also use the QBoxLayout
constuctor directly, specifying its direction as LeftToRight, Down, RightToLeft
or Up.
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->addLayout().
Once you have done that, you can add boxes to the QBoxLayout using one of four functions:
Finally, if the layout is a top-level one, you activate() it.
QBoxLayout also includes two margin widths: The border width and the inter-box width. The border width is the width of the reserved space along each of the QBoxLayout's four sides. The intra-widget width is the width of the automatically allocated spacing between neighbouring boxes. (You can use addSpacing() to get more space.)
The border width defaults to 0, and the intra-widget width defaults to the same as the border width. Both are set using arguments to the constructor.
You will almost always want to use the convenience classes for QBoxLayout: QVBoxLayout and QHBoxLayout, because of their simpler constructors.
Examples: pref/pref.cpp layout/layout.cpp
Creates a new QBoxLayout with direction d and main widget parent. parent may not be 0.
border is the number of pixels between the edge of the widget and the managed children. autoBorder is the default number of pixels between neighbouring children. If autoBorder is -1 the value of border is used.
name is the internal object name
See also: direction().
Examples: layout/layout.cpp
If autoBorder is -1, this QBoxLayout will inherit its parent's defaultBorder(), otherwise autoBorder is used.
You have to insert this box into another layout before using it.
Destroys this box.
Adds layout to the box, with serial stretch factor stretch.
See also: addWidget() and addSpacing().
Examples: pref/pref.cpp layout/layout.cpp widgets/widgets.cpp
Adds a non-stretchable space with size size. QBoxLayout gives default border and spacing. This function adds additional space.
See also: addStretch().
Examples: widgets/widgets.cpp
Adds a stretchable space with zero minimum size and stretch factor stretch.
See also: addSpacing().
Examples: pref/pref.cpp widgets/widgets.cpp
Limits the perpendicular dimension of the box (e.g. height if the box is LeftToRight) to a minimum of size. Other constraints may increase the limit.
Adds widget to the box, with stretch factor stretch and alignment align.
The stretch factor applies only in the direction of the QBoxLayout, and is relative to the other boxes and widgets in this QBoxLayout. Widgets and boxes with higher stretch factor grow more.
If the stretch factor is 0 and nothing else in the QBoxLayout can grow at all, the widget may still grow up to its maximum size.
Alignment is perpendicular to direction(), alignment in the serial direction is done with addStretch().
For horizontal boxes, the possible alignments are
AlignCenter
centers vertically in the box.
AlignTop
aligns to the top border of the box.
AlignBottom
aligns to the bottom border of the box.
For vertical boxes, the possible alignments are
AlignCenter
centers horizontally in the box.
AlignLeft
aligns to the left border of the box.
AlignRight
aligns to the right border of the box.
Alignment only has effect if the size of the box is greater than the widget's maximum size.
See also: addLayout() and addSpacing().
Examples: pref/pref.cpp layout/layout.cpp widgets/widgets.cpp
Returns the (serial) direction of the box. addWidget(), addBox() and addSpacing() works in this direction; the stretch stretches in this direction. Alignment works perpendicular to this direction.
The directions are LeftToRight, RightToLeft, TopToBottom
and BottomToTop.
For the last two, the shorter aliases Down
and
Up
are also available.
See also: addWidget(), addBox() and addSpacing().
[virtual protected]
Initializes this box.
Reimplemented from QLayout.
[virtual protected]
Returns the main horizontal chain, so that a box can be put into other boxes (or other types of QLayout).
Reimplemented from QLayout.
[virtual protected]
Returns the main vertical chain, so that a box can be put into other boxes (or other types of QLayout).
Reimplemented from QLayout.
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-98 Troll Tech, all rights reserved.
It was generated from the following files:
Copyright © 1998 Troll Tech | Trademarks | Qt version 1.42
|