QBoxLayout Class Reference


The QBoxLayout class specifies child widget geometry. More... More...

#include <qlayout.h>

Inherits QLayout.

Inherited by QHBoxLayout and QVBoxLayout.

List of all member functions.

Public Members

Protected Members


Detailed Description

The QBoxLayout class specifies child widget geometry. More...

Contents are arranged serially, either horizontal or vertical. The contents fill the available space.

A QBoxLayout can contain widgets or other layouts.

QHBoxLayout and QVBoxLayout are convenience classes.

Warning: The current version does not support deletion of child widgets. If you need to remove widgets that are under geometry management, you have to delete the layout manager first.

Examples: pref/pref.cpp layout/layout.cpp


Member Function Documentation

QBoxLayout::QBoxLayout ( QWidget * parent, Direction d, int border=0, int autoBorder = -1, const char * name=0 )

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 adjacent managed children. If autoBorder is -1 the value of border is used.

name is the internal object name

See also: direction().

Examples: layout/layout.cpp

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

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.

QBoxLayout::~QBoxLayout ()

Destroys this box.

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

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

void QBoxLayout::addSpacing ( int size )

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

void QBoxLayout::addStretch ( int stretch = 0 )

Adds a stretchable space with zero minimum size and stretch factor stretch.

See also: addSpacing.

Examples: pref/pref.cpp widgets/widgets.cpp

void QBoxLayout::addStrut ( int size )

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.

See also: addMaxStrut().

void QBoxLayout::addWidget ( QWidget * widget, int stretch = 0, int align = AlignCenter )

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

For vertical boxes, the possible alignments are

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

QBoxLayout::Direction QBoxLayout::direction() const

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().

void QBoxLayout::initGM () [virtual protected]

Initializes this box.

Reimplemented from QLayout.

QChain * QBoxLayout::mainHorizontalChain () [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.

QChain * QBoxLayout::mainVerticalChain () [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.


This file is part of the Qt toolkit, copyright © 1995-97 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 13:30, 1998/01/15 for Qt version 1.32 by the webmaster at Troll Tech