Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QBoxLayout class lines up child widgets horizontally or vertically. More...
#include <qlayout.h>
Inherits QLayout.
Inherited by QHBoxLayout and QVBoxLayout.
The QBoxLayout class lines up child widgets horizontally or vertically.
QBoxLayout takes the space it gets (from its parent layout or from the mainWidget()), divides it up into a row of boxes, and makes each managed widget fill one box.
If the QBoxLayout's orientation is Horizontal the boxes are placed in a row, with suitable sizes. Each widget (or other box) will get at least its minimum size and at most its maximum size. Any excess space is shared according to the stretch factors (more about that below).
If the QBoxLayout's orientation is Vertical, the boxes are placed in a column, again with suitable sizes.
The easiest way to create a QBoxLayout is to use one of the convenience classes, e.g. QHBoxLayout (for Horizontal boxes) or QVBoxLayout (for Vertical boxes). You can also use the QBoxLayout constructor directly, specifying its direction as LeftToRight, Down, RightToLeft or Up.
If the QBoxLayout is not the top-level layout (i.e. it 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 this, you can add boxes to the QBoxLayout using one of four functions:
Use insertWidget(), insertSpacing(), insertStretch() or insertLayout() to insert a box at a specified position in the layout.
QBoxLayout also includes two margin widths:
The margin defaults to 0. The spacing defaults to the same as the margin width for a top-level layout, or to the same as the parent layout. Both are parameters to the constructor.
To remove a widget from a layout, call remove(). Calling QWidget::hide() on a widget also effectively removes the widget from the layout until QWidget::show() is called.
You will almost always want to use QVBoxLayout and QHBoxLayout rather than QBoxLayout because of their convenient constructors.
See also QGrid, Layout Overview, Widget Appearance and Style, and Layout Management.
This type is used to determine the direction of a box layout.
The margin is the number of pixels between the edge of the widget and its managed children. The spacing is the default number of pixels between neighboring children. If spacing is -1 the value of margin is used for spacing.
name is the internal object name.
See also direction().
The spacing is the default number of pixels between neighboring children. If spacing is -1, the layout will inherit its parent's spacing().
If spacing is -1, the layout will inherit its parent's spacing(); otherwise spacing is used.
You must insert this box into another layout.
The layout's widgets aren't destroyed.
Examples: chart/optionsform.cpp and chart/setdataform.cpp.
Reimplemented from QLayout.
See also insertLayout(), setAutoAdd(), addWidget(), and addSpacing().
Examples: chart/optionsform.cpp, chart/setdataform.cpp, fonts/simple-qfont-demo/viewer.cpp, listbox/listbox.cpp, and tictac/tictac.cpp.
See also insertSpacing() and addStretch().
Example: listbox/listbox.cpp.
See also addSpacing().
Examples: layout/layout.cpp, listbox/listbox.cpp, and t13/gamebrd.cpp.
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 factors grow more.
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.
Alignment is specified by alignment which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell.
From Qt 3.0, 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 sizeHint().
See also insertWidget(), setAutoAdd(), addLayout(), and addSpacing().
Examples: chart/optionsform.cpp, checklists/checklists.cpp, layout/layout.cpp, lineedits/lineedits.cpp, listbox/listbox.cpp, t13/gamebrd.cpp, and t13/lcdrange.cpp.
Returns the direction of the box. addWidget() and addSpacing() work in this direction; the stretch stretches in this direction.
See also QBoxLayout::Direction, addWidget(), and addSpacing().
Reimplemented from QLayout.
Returns the index of w, or -1 if w is not found.
Reimplemented from QLayoutItem.
Reimplemented from QLayoutItem.
Warning: Does not call QLayout::insertChildLayout() if item is a QLayout.
See also addItem() and findWidget().
layout becomes a child of the box layout.
See also setAutoAdd(), insertWidget(), and insertSpacing().
The box layout has default margin and spacing. This function adds additional space.
See also insertStretch().
See also insertSpacing().
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 factors grow more.
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.
Alignment is specified by alignment, which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell.
From Qt 3.0, 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 sizeHint().
See also setAutoAdd(), insertLayout(), and insertSpacing().
Reimplemented from QLayout.
Reimplemented from QLayout.
Reimplemented from QLayout.
Reimplemented from QLayout.
Sets the stretch factor for the layout l to stretch and returns TRUE if l is found in this layout (not including child layouts); otherwise returns FALSE.
Reimplemented from QLayoutItem.
This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.
Copyright © 2003 Trolltech | Trademarks | Qt version 3.2.0b2
|