Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QBoxLayout class lines up child widgets horizontally or vertically. More...
#include <QBoxLayout>
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 parentWidget()), divides it up into a row of boxes, and makes each managed widget fill one box.
If the QBoxLayout's orientation is Qt::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 Qt::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 Qt::Horizontal boxes) or QVBoxLayout (for Qt::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 and Layout Overview.
This type is used to determine the direction of a box layout.
QBoxLayout::LeftToRight | Qt::Horizontal, from left to right |
QBoxLayout::RightToLeft | Qt::Horizontal, from right to left |
QBoxLayout::TopToBottom | Qt::Vertical, from top to bottom |
QBoxLayout::Down | The same as TopToBottom |
QBoxLayout::BottomToTop | Qt::Vertical, from bottom to top |
QBoxLayout::Up | The same as BottomToTop |
Constructs a new QBoxLayout with direction dir and parent widget parent. parent may not be 0.
See also direction().
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Constructs a new QBoxLayout, with direction dir, and inserts it into parentLayout.
Constructs a new QBoxLayout with direction dir.
You must insert this box into another layout.
Destroys this box layout.
The layout's widgets aren't destroyed.
Adds item to the end of this box layout.
Reimplemented from QLayout.
Adds layout to the end of the box, with serial stretch factor stretch.
See also insertLayout(), addWidget(), and addSpacing().
Adds a non-stretchable space with size size to the end of this box layout. QBoxLayout provides default margin and spacing. This function adds additional space.
See also insertSpacing() and addStretch().
Adds a stretchable space with zero minimum size and stretch factor stretch to the end of this box layout.
See also addSpacing().
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 end of this box layout, with a stretch factor of stretch and alignment alignment.
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.
The alignment is specified by alignment. 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(), addLayout(), and addSpacing().
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().
Returns whether this layout can make use of more space than sizeHint(). A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, whereas BothDirections means that it wants to grow in both dimensions.
Reimplemented from QLayoutItem.
Searches for widget w in this layout (not including child layouts).
Returns the index of w, or -1 if w is not found.
Returns true if this layout's preferred height depends on its width; otherwise returns false.
Reimplemented from QLayoutItem.
Returns the layout's preferred height when it is w pixels wide.
Reimplemented from QLayoutItem.
Inserts item into this box layout at position index. If index is negative, the item is added at the end.
Warning: Does not call QLayout::insertChildLayout() if item is a QLayout.
See also addItem() and findWidget().
Inserts layout at position index, with stretch factor stretch. If index is negative, the layout is added at the end.
layout becomes a child of the box layout.
See also insertWidget() and insertSpacing().
Inserts a non-stretchable space at position index, with size size. If index is negative the space is added at the end.
The box layout has default margin and spacing. This function adds additional space.
See also insertStretch().
Inserts a stretchable space at position index, with zero minimum size and stretch factor stretch. If index is negative the space is added at the end.
See also insertSpacing().
Inserts widget at position index, with stretch factor stretch and alignment alignment. If index is negative, the widget is added at the end.
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.
The alignment is specified by alignment. 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 insertLayout() and insertSpacing().
Resets cached information.
Reimplemented from QLayoutItem.
Returns the maximum size needed by this box layout.
Reimplemented from QLayoutItem.
Returns the minimum size needed by this box layout.
Reimplemented from QLayoutItem.
Sets the alignment for widget w to alignment and returns true if w is found in this layout (not including child layouts); otherwise returns false.
See also setStretchFactor().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the alignment for the box layout to be alignment.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the alignment for the layout l to alignment and returns true if l is found in this layout (not including child layouts); otherwise returns false.
Sets the direction of this layout to direction.
Resizes managed widgets within the rectangle r.
Reimplemented from QLayoutItem.
Sets the stretch factor for widget w to stretch and returns true if w is found in this layout (not including child layouts); otherwise returns false.
See also setAlignment().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
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.
Returns the preferred size of this box layout.
Reimplemented from QLayoutItem.
Copyright © 2004 Trolltech. | Trademarks | Qt 4.0.0-tp1 |