QBoxLayout Class Reference

#include <qboxlayout.h>

Inheritance diagram for QBoxLayout:

Inheritance graph
[legend]
Collaboration diagram for QBoxLayout:

Collaboration graph
[legend]
List of all members.

Detailed Description

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.

Horizontal box layout with five child widgets

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

Vertical box layout with five child widgets

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, RightToLeft, TopToBottom, or BottomToTop.

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:

addWidget() to add a widget to the QBoxLayout and set the widget's stretch factor. (The stretch factor is along the row of boxes.)

addSpacing() to create an empty box; this is one of the functions you use to create nice and spacious dialogs. See below for ways to set margins.

addStretch() to create an empty, stretchable box.

addLayout() to add a box containing another QLayout to the row and set that layout's stretch factor.

Use insertWidget(), insertSpacing(), insertStretch() or insertLayout() to insert a box at a specified position in the layout.

QBoxLayout also includes two margin widths:

setMargin() sets the width of the outer border. This is the width of the reserved space along each of the QBoxLayout's four sides. setSpacing() sets the width between neighboring boxes. (You can use addSpacing() to get more space at a particular spot.)

The margin default is provided by the style. The default margin most Qt styles specify is 9 for child widgets and 11 for windows. The spacing defaults to the same as the margin width for a top-level layout, or to the same as the parent layout.

To remove a widget from a layout, call removeWidget(). 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:
QGridLayout, QStackedLayout, {Layout Classes}

Definition at line 40 of file qboxlayout.h.

Public Types

enum  Direction

Public Member Functions

 QBoxLayout (Direction, QWidget *parent=0)
 ~QBoxLayout ()
Direction direction () const
void setDirection (Direction)
void addSpacing (int size)
void addStretch (int stretch=0)
void addWidget (QWidget *, int stretch=0, Qt::Alignment alignment=0)
void addLayout (QLayout *layout, int stretch=0)
void addStrut (int)
void addItem (QLayoutItem *)
void insertSpacing (int index, int size)
void insertStretch (int index, int stretch=0)
void insertWidget (int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=0)
void insertLayout (int index, QLayout *layout, int stretch=0)
bool setStretchFactor (QWidget *w, int stretch)
bool setStretchFactor (QLayout *l, int stretch)
QSize sizeHint () const
QSize minimumSize () const
QSize maximumSize () const
bool hasHeightForWidth () const
int heightForWidth (int) const
int minimumHeightForWidth (int) const
Qt::Orientations expandingDirections () const
void invalidate ()
QLayoutItemitemAt (int) const
QLayoutItemtakeAt (int)
int count () const
void setGeometry (const QRect &)

Protected Member Functions

void insertItem (int index, QLayoutItem *)


Member Enumeration Documentation

enum QBoxLayout::Direction

This type is used to determine the direction of a box layout.

LeftToRight Horizontal from left to right. RightToLeft Horizontal from right to left. TopToBottom Vertical from top to bottom. BottomToTop Vertical from bottom to top.

Down Up

Definition at line 45 of file qboxlayout.h.

00045                    { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
00046                      Down = TopToBottom, Up = BottomToTop };


Constructor & Destructor Documentation

QBoxLayout::QBoxLayout ( Direction  dir,
QWidget parent = 0 
) [explicit]

Constructs a new QBoxLayout with direction dir and parent widget parent.

See also:
direction()

Definition at line 365 of file qboxlayout.cpp.

References d.

00366     : QLayout(*new QBoxLayoutPrivate, 0, parent)
00367 {
00368     Q_D(QBoxLayout);
00369     d->dir = dir;
00370 }

QBoxLayout::~QBoxLayout (  ) 

Destroys this box layout.

The layout's widgets aren't destroyed.

Definition at line 439 of file qboxlayout.cpp.

References d.

00440 {
00441     Q_D(QBoxLayout);
00442     d->deleteAll(); // must do it before QObject deletes children, so can't be in ~QBoxLayoutPrivate
00443 }


Member Function Documentation

QBoxLayout::Direction QBoxLayout::direction (  )  const

Returns the direction of the box. addWidget() and addSpacing() work in this direction; the stretch stretches in this direction.

See also:
QBoxLayout::Direction addWidget() addSpacing()

Definition at line 974 of file qboxlayout.cpp.

References d.

Referenced by Q3DockWindow::handleMove(), and QToolBar::resizeEvent().

00975 {
00976     Q_D(const QBoxLayout);
00977     return d->dir;
00978 }

void QBoxLayout::setDirection ( Direction  direction  ) 

Sets the direction of this layout to direction.

Definition at line 926 of file qboxlayout.cpp.

References QSpacerItem::changeSize(), d, QSizePolicy::Expanding, QSpacerItem::expandingDirections(), QSizePolicy::Fixed, horz(), i, invalidate(), QSizePolicy::Minimum, s, and QSpacerItem::sizeHint().

Referenced by QToolBar::setOrientation(), and Q3DockWindow::setOrientation().

00927 {
00928     Q_D(QBoxLayout);
00929     if (d->dir == direction)
00930         return;
00931     if (horz(d->dir) != horz(direction)) {
00932         //swap around the spacers (the "magic" bits)
00933         //#### a bit yucky, knows too much.
00934         //#### probably best to add access functions to spacerItem
00935         //#### or even a QSpacerItem::flip()
00936         for (int i = 0; i < d->list.size(); ++i) {
00937             QBoxLayoutItem *box = d->list.at(i);
00938             if (box->magic) {
00939                 QSpacerItem *sp = box->item->spacerItem();
00940                 if (sp) {
00941                     if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) {
00942                         //spacing or strut
00943                         QSize s = sp->sizeHint();
00944                         sp->changeSize(s.height(), s.width(),
00945                             horz(direction) ? QSizePolicy::Fixed:QSizePolicy::Minimum,
00946                             horz(direction) ? QSizePolicy::Minimum:QSizePolicy::Fixed);
00947 
00948                     } else {
00949                         //stretch
00950                         if (horz(direction))
00951                             sp->changeSize(0, 0, QSizePolicy::Expanding,
00952                                             QSizePolicy::Minimum);
00953                         else
00954                             sp->changeSize(0, 0, QSizePolicy::Minimum,
00955                                             QSizePolicy::Expanding);
00956                     }
00957                 }
00958             }
00959         }
00960     }
00961     d->dir = direction;
00962     invalidate();
00963 }

Here is the call graph for this function:

void QBoxLayout::addSpacing ( int  size  ) 

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(), addItem()

Definition at line 801 of file qboxlayout.cpp.

References insertSpacing().

Referenced by Q3FileDialog::addLeftWidget(), Q3FileDialog::addRightWidget(), Q3FileDialog::addToolButton(), Q3FileDialog::addWidgets(), ConfigDialog::ConfigDialog(), QColorDialogPrivate::init(), Q3DockWindow::init(), KAstTopLevel::KAstTopLevel(), QDialogButtonBoxPrivate::layoutButtons(), QueryPage::QueryPage(), QStatusBar::reformat(), SpreadSheet::runInputDialog(), Q3TabDialog::setUpLayout(), UpdatePage::UpdatePage(), and XFormWidget::XFormWidget().

00802 {
00803     insertSpacing(-1, size);
00804 }

Here is the call graph for this function:

void QBoxLayout::addStretch ( int  stretch = 0  ) 

Adds a stretchable space with zero minimum size and stretch factor stretch to the end of this box layout.

See also:
insertStretch(), addItem()

Definition at line 812 of file qboxlayout.cpp.

References insertStretch().

Referenced by ColorDock::changeSizeHints(), CompositionWidget::CompositionWidget(), ConfigDialog::ConfigDialog(), ConfigurationPage::ConfigurationPage(), ControllerWindow::ControllerWindow(), MoviePlayer::createButtons(), Screenshot::createButtonsLayout(), Window::createFirstExclusiveGroup(), Window::createIconGroupBox(), MainWindow::createIconSizeGroupBox(), FindFileDialog::createLayout(), Window::createNonExclusiveGroup(), Window::createPushButtonGroup(), Window::createSecondExclusiveGroup(), GameBoard::GameBoard(), GeneralTab::GeneralTab(), GradientWidget::GradientWidget(), QColorDialogPrivate::init(), QInputDialogPrivate::init(), Q3DockWindow::init(), KAstTopLevel::KAstTopLevel(), QDialogButtonBoxPrivate::layoutButtons(), PathDeformWidget::PathDeformWidget(), PathStrokeWidget::PathStrokeWidget(), PermissionsTab::PermissionsTab(), QueryPage::QueryPage(), Receiver::Receiver(), RegExpDialog::RegExpDialog(), qdesigner_internal::RichTextEditorDialog::RichTextEditorDialog(), SpreadSheet::runInputDialog(), Server::Server(), Q3TabDialog::setUpLayout(), qdesigner_internal::SignalSlotEditorWindow::SignalSlotEditorWindow(), UpdatePage::UpdatePage(), View::View(), WidgetGallery::WidgetGallery(), Window::Window(), and XFormWidget::XFormWidget().

00813 {
00814     insertStretch(-1, stretch);
00815 }

Here is the call graph for this function:

void QBoxLayout::addWidget ( QWidget widget,
int  stretch = 0,
Qt::Alignment  alignment = 0 
)

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

See also:
insertWidget(), addItem(), addLayout(), addStretch(), addSpacing(), addStrut()

Definition at line 837 of file qboxlayout.cpp.

References insertWidget(), and QLayoutItem::widget().

Referenced by qdesigner_internal::add_to_box_layout(), QDialogButtonBoxPrivate::addButtonsToLayout(), Q3FileDialog::addLeftWidget(), Q3FileDialog::addRightWidget(), Q3FileDialog::addToolButton(), Q3FileDialog::addWidgets(), AnimationSaveWidget::AnimationSaveWidget(), ColorDock::changeSizeHints(), CompositionWidget::CompositionWidget(), ConfigDialog::ConfigDialog(), ConfigurationPage::ConfigurationPage(), ControllerWindow::ControllerWindow(), WidgetGallery::createBottomLeftTabWidget(), MoviePlayer::createButtons(), Screenshot::createButtonsLayout(), Window::createDoubleSpinBoxes(), Window::createFirstExclusiveGroup(), MainWindow::createGroupBox(), QCalendarWidgetPrivate::createHeader(), Window::createIconGroupBox(), MainWindow::createIconSizeGroupBox(), FindFileDialog::createLayout(), Window::createNonExclusiveGroup(), Window::createPushButtonGroup(), Window::createSecondExclusiveGroup(), Window::createSpinBoxes(), DropSiteWindow::DropSiteWindow(), EditorWithReset::EditorWithReset(), Q3ToolBar::event(), FtpWindow::FtpWindow(), GameBoard::GameBoard(), GeneralTab::GeneralTab(), GradientEditor::GradientEditor(), GradientWidget::GradientWidget(), HttpWindow::HttpWindow(), QWorkspaceChild::iconWidget(), QColorDialogPrivate::init(), Q3FileDialog::init(), QInputDialogPrivate::init(), Q3DockWindow::init(), KAstTopLevel::KAstTopLevel(), LanguageChooser::LanguageChooser(), Q3Wizard::layOut(), QDialogButtonBoxPrivate::layoutButtons(), LocationDialog::LocationDialog(), main(), MessageEditor::MessageEditor(), MoviePlayer::MoviePlayer(), MyWidget::MyWidget(), qdesigner_internal::ObjectInspector::ObjectInspector(), qdesigner_internal::OldSignalSlotDialog::OldSignalSlotDialog(), PathDeformWidget::PathDeformWidget(), PathStrokeWidget::PathStrokeWidget(), PermissionsTab::PermissionsTab(), qdesigner_internal::PreviewFrame::PreviewFrame(), PreviewFrame::PreviewFrame(), PrintPanel::PrintPanel(), qdesigner_internal::PropertyEditor::PropertyEditor(), QCalendarPopup::QCalendarPopup(), QCalendarWidget::QCalendarWidget(), QDBusViewer::QDBusViewer(), QFontDialog::QFontDialog(), QPageSetupDialog::QPageSetupDialog(), QueryPage::QueryPage(), QVFbRateDialog::QVFbRateDialog(), Receiver::Receiver(), RegExpDialog::RegExpDialog(), QToolBoxPrivate::relayout(), qdesigner_internal::RichTextEditorDialog::RichTextEditorDialog(), SpreadSheet::runInputDialog(), Screenshot::Screenshot(), Sender::Sender(), Server::Server(), Q3TabDialog::setUpLayout(), QFileDialogPrivate::setupToolButtons(), MainWindow::setupWidgets(), Q3DockWindow::setWidget(), qdesigner_internal::SignalSlotEditorWindow::SignalSlotEditorWindow(), SlidersGroup::SlidersGroup(), TabDialog::TabDialog(), TableEditor::TableEditor(), TicTacToeDialog::TicTacToeDialog(), TransEditor::TransEditor(), TrWindow::TrWindow(), UpdatePage::UpdatePage(), View::View(), WidgetGallery::WidgetGallery(), Window::Window(), and XFormWidget::XFormWidget().

00838 {
00839     insertWidget(-1, widget, stretch, alignment);
00840 }

Here is the call graph for this function:

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

Adds layout to the end of the box, with serial stretch factor stretch.

See also:
insertLayout(), addItem(), addWidget()

Definition at line 848 of file qboxlayout.cpp.

References insertLayout(), and QLayout::layout().

Referenced by Q3FileDialog::addWidgets(), ColorDock::changeSizeHints(), ConfigDialog::ConfigDialog(), ConfigurationPage::ConfigurationPage(), ControllerWindow::ControllerWindow(), FindFileDialog::createLayout(), FtpWindow::FtpWindow(), HttpWindow::HttpWindow(), QColorDialogPrivate::init(), Q3FileDialog::init(), Q3DockWindow::init(), KAstTopLevel::KAstTopLevel(), Q3Wizard::layOut(), MoviePlayer::MoviePlayer(), qdesigner_internal::OldSignalSlotDialog::OldSignalSlotDialog(), QDBusViewer::QDBusViewer(), Receiver::Receiver(), QStatusBar::reformat(), Screenshot::Screenshot(), Server::Server(), Q3GroupBox::setColumnLayout(), and Q3TabDialog::setUpLayout().

00849 {
00850     insertLayout(-1, layout, stretch);
00851 }

Here is the call graph for this function:

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:
addItem()

Definition at line 860 of file qboxlayout.cpp.

References b, d, QSizePolicy::Fixed, horz(), invalidate(), QBoxLayoutItem::magic, and QSizePolicy::Minimum.

Referenced by KAstTopLevel::KAstTopLevel().

00861 {
00862     Q_D(QBoxLayout);
00863     QLayoutItem *b;
00864     if (horz(d->dir))
00865         b = new QSpacerItem(0, size, QSizePolicy::Fixed, QSizePolicy::Minimum);
00866     else
00867         b = new QSpacerItem(size, 0, QSizePolicy::Minimum, QSizePolicy::Fixed);
00868 
00869     QBoxLayoutItem *it = new QBoxLayoutItem(b);
00870     it->magic = true;
00871     d->list.append(it);
00872     invalidate();
00873 }

Here is the call graph for this function:

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

Implements QLayout.

Definition at line 654 of file qboxlayout.cpp.

References d, and invalidate().

Referenced by qdesigner_internal::add_to_box_layout(), QCalendarWidgetPrivate::createHeader(), QDockWidgetPrivate::init(), QPageSetupDialog::QPageSetupDialog(), QVFbRateDialog::QVFbRateDialog(), and SpreadSheet::runInputDialog().

00655 {
00656     Q_D(QBoxLayout);
00657     QBoxLayoutItem *it = new QBoxLayoutItem(item);
00658     d->list.append(it);
00659     invalidate();
00660 }

Here is the call graph for this function:

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

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:
addSpacing(), insertItem()

Definition at line 692 of file qboxlayout.cpp.

References b, d, QSizePolicy::Fixed, horz(), invalidate(), QBoxLayoutItem::magic, and QSizePolicy::Minimum.

Referenced by addSpacing().

00693 {
00694     Q_D(QBoxLayout);
00695     if (index < 0)                                // append
00696         index = d->list.count();
00697 
00698     QLayoutItem *b;
00699     if (horz(d->dir))
00700         b = new QSpacerItem(size, 0, QSizePolicy::Fixed,
00701                              QSizePolicy::Minimum);
00702     else
00703         b = new QSpacerItem(0, size, QSizePolicy::Minimum,
00704                              QSizePolicy::Fixed);
00705 
00706     QBoxLayoutItem *it = new QBoxLayoutItem(b);
00707     it->magic = true;
00708     d->list.insert(index, it);
00709     invalidate();
00710 }

Here is the call graph for this function:

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

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:
addStretch(), insertItem()

Definition at line 719 of file qboxlayout.cpp.

References b, d, QSizePolicy::Expanding, horz(), invalidate(), QBoxLayoutItem::magic, and QSizePolicy::Minimum.

Referenced by addStretch(), and QCalendarWidgetPrivate::createHeader().

00720 {
00721     Q_D(QBoxLayout);
00722     if (index < 0)                                // append
00723         index = d->list.count();
00724 
00725     QLayoutItem *b;
00726     if (horz(d->dir))
00727         b = new QSpacerItem(0, 0, QSizePolicy::Expanding,
00728                              QSizePolicy::Minimum);
00729     else
00730         b = new QSpacerItem(0, 0, QSizePolicy::Minimum,
00731                              QSizePolicy::Expanding);
00732 
00733     QBoxLayoutItem *it = new QBoxLayoutItem(b, stretch);
00734     it->magic = true;
00735     d->list.insert(index, it);
00736     invalidate();
00737 }

Here is the call graph for this function:

void QBoxLayout::insertWidget ( int  index,
QWidget widget,
int  stretch = 0,
Qt::Alignment  alignment = 0 
)

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

See also:
addWidget(), insertItem()

Definition at line 778 of file qboxlayout.cpp.

References QLayout::addChildWidget(), b, checkWidget(), d, invalidate(), and QLayoutItem::widget().

Referenced by addWidget(), qdesigner_internal::insert_into_box_layout(), QAbstractScrollAreaPrivate::replaceScrollBar(), and EditorWithReset::setChildEditor().

00780 {
00781     Q_D(QBoxLayout);
00782     if (!checkWidget(this, widget))
00783          return;
00784     addChildWidget(widget);
00785     if (index < 0)                                // append
00786         index = d->list.count();
00787     QWidgetItem *b = new QWidgetItem(widget);
00788     b->setAlignment(alignment);
00789     QBoxLayoutItem *it = new QBoxLayoutItem(b, stretch);
00790     d->list.insert(index, it);
00791     invalidate();
00792 }

Here is the call graph for this function:

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

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:
addLayout(), insertItem()

Definition at line 747 of file qboxlayout.cpp.

References QLayout::addChildLayout(), d, invalidate(), and QLayout::layout().

Referenced by addLayout().

00748 {
00749     Q_D(QBoxLayout);
00750     addChildLayout(layout);
00751     if (index < 0)                                // append
00752         index = d->list.count();
00753     QBoxLayoutItem *it = new QBoxLayoutItem(layout, stretch);
00754     d->list.insert(index, it);
00755     invalidate();
00756 }

Here is the call graph for this function:

bool QBoxLayout::setStretchFactor ( QWidget widget,
int  stretch 
)

Sets the stretch factor for widget to stretch and returns true if widget is found in this layout (not including child layouts); otherwise returns false.

See also:
setAlignment()

Definition at line 888 of file qboxlayout.cpp.

References d, i, invalidate(), and QLayoutItem::widget().

Referenced by Q3ToolBar::event(), Q3FileDialog::init(), and Q3ToolBar::setStretchableWidget().

00889 {
00890     Q_D(QBoxLayout);
00891     for (int i = 0; i < d->list.size(); ++i) {
00892         QBoxLayoutItem *box = d->list.at(i);
00893         if (box->item->widget() == widget) {
00894             box->stretch = stretch;
00895             invalidate();
00896             return true;
00897         }
00898     }
00899     return false;
00900 }

Here is the call graph for this function:

bool QBoxLayout::setStretchFactor ( QLayout layout,
int  stretch 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the stretch factor for the layout layout to stretch and returns true if layout is found in this layout (not including child layouts); otherwise returns false.

Definition at line 909 of file qboxlayout.cpp.

References d, i, invalidate(), and QLayout::layout().

00910 {
00911     Q_D(QBoxLayout);
00912     for (int i = 0; i < d->list.size(); ++i) {
00913         QBoxLayoutItem *box = d->list.at(i);
00914         if (box->item->layout() == layout) {
00915             box->stretch = stretch;
00916             invalidate();
00917             return true;
00918         }
00919     }
00920     return false;
00921 }

Here is the call graph for this function:

QSize QBoxLayout::sizeHint (  )  const [virtual]

Implements QLayoutItem.

Definition at line 448 of file qboxlayout.cpp.

References d, m, and QLayout::margin().

Referenced by setGeometry().

00449 {
00450     Q_D(const QBoxLayout);
00451     if (d->dirty)
00452         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00453     int m = margin();
00454     return d->sizeHint + QSize(2 * m, 2 * m);
00455 }

Here is the call graph for this function:

QSize QBoxLayout::minimumSize (  )  const [virtual]

Reimplemented from QLayout.

Definition at line 460 of file qboxlayout.cpp.

References d, m, and QLayout::margin().

Referenced by setGeometry().

00461 {
00462     Q_D(const QBoxLayout);
00463     if (d->dirty)
00464         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00465     int m = margin();
00466     return d->minSize + QSize(2 * m, 2 * m);
00467 }

Here is the call graph for this function:

QSize QBoxLayout::maximumSize (  )  const [virtual]

Reimplemented from QLayout.

Definition at line 472 of file qboxlayout.cpp.

References Qt::AlignHorizontal_Mask, QLayoutItem::alignment(), Qt::AlignVertical_Mask, d, m, QLayout::margin(), QLAYOUTSIZE_MAX, and s.

00473 {
00474     Q_D(const QBoxLayout);
00475     if (d->dirty)
00476         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00477     int m = margin();
00478     QSize s = (d->maxSize + QSize(2 * m, 2 * m))
00479               .boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX));
00480     if (alignment() & Qt::AlignHorizontal_Mask)
00481         s.setWidth(QLAYOUTSIZE_MAX);
00482     if (alignment() & Qt::AlignVertical_Mask)
00483         s.setHeight(QLAYOUTSIZE_MAX);
00484     return s;
00485 }

Here is the call graph for this function:

bool QBoxLayout::hasHeightForWidth (  )  const [virtual]

Reimplemented from QLayoutItem.

Definition at line 490 of file qboxlayout.cpp.

References d.

Referenced by heightForWidth().

00491 {
00492     Q_D(const QBoxLayout);
00493     if (d->dirty)
00494         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00495     return d->hasHfw;
00496 }

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

Reimplemented from QLayoutItem.

Definition at line 501 of file qboxlayout.cpp.

References d, hasHeightForWidth(), m, and QLayout::margin().

Referenced by minimumHeightForWidth().

00502 {
00503     Q_D(const QBoxLayout);
00504     if (!hasHeightForWidth())
00505         return -1;
00506     int m = margin();
00507     w -= 2 * m;
00508     if (w != d->hfwWidth)
00509         const_cast<QBoxLayout*>(this)->d_func()->calcHfw(w);
00510 
00511     return d->hfwHeight + 2 * m;
00512 }

Here is the call graph for this function:

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

Reimplemented from QLayoutItem.

Definition at line 517 of file qboxlayout.cpp.

References d, heightForWidth(), and QLayout::margin().

00518 {
00519     Q_D(const QBoxLayout);
00520     (void) heightForWidth(w);
00521     return d->hasHfw ? (d->hfwMinHeight + 2 * margin()) : -1;
00522 }

Here is the call graph for this function:

Qt::Orientations QBoxLayout::expandingDirections (  )  const [virtual]

Reimplemented from QLayout.

Definition at line 573 of file qboxlayout.cpp.

References d.

00574 {
00575     Q_D(const QBoxLayout);
00576     if (d->dirty)
00577         const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
00578     return d->expanding;
00579 }

void QBoxLayout::invalidate (  )  [virtual]

Resets cached information.

Reimplemented from QLayout.

Definition at line 527 of file qboxlayout.cpp.

References d, and QLayout::invalidate().

Referenced by addItem(), addStrut(), insertItem(), insertLayout(), insertSpacing(), insertStretch(), insertWidget(), QDockWidgetPrivate::relayout(), setDirection(), setStretchFactor(), and takeAt().

00528 {
00529     Q_D(QBoxLayout);
00530     d->setDirty();
00531     QLayout::invalidate();
00532 }

Here is the call graph for this function:

QLayoutItem * QBoxLayout::itemAt ( int  index  )  const [virtual]

Implements QLayout.

Definition at line 546 of file qboxlayout.cpp.

References d.

Referenced by QDialogButtonBoxPrivate::layoutButtons(), and QToolBar::resizeEvent().

00547 {
00548     Q_D(const QBoxLayout);
00549     return index >= 0 && index < d->list.count() ? d->list.at(index)->item : 0;
00550 }

QLayoutItem * QBoxLayout::takeAt ( int  index  )  [virtual]

Implements QLayout.

Definition at line 555 of file qboxlayout.cpp.

References b, d, and invalidate().

Referenced by QDialogButtonBoxPrivate::layoutButtons().

00556 {
00557     Q_D(QBoxLayout);
00558     if (index < 0 || index >= d->list.count())
00559         return 0;
00560     QBoxLayoutItem *b = d->list.takeAt(index);
00561     QLayoutItem *item = b->item;
00562     b->item = 0;
00563     delete b;
00564 
00565     invalidate();
00566     return item;
00567 }

Here is the call graph for this function:

int QBoxLayout::count (  )  const [virtual]

Implements QLayout.

Definition at line 537 of file qboxlayout.cpp.

References d.

Referenced by QCalendarWidgetPrivate::createHeader(), and QDialogButtonBoxPrivate::layoutButtons().

00538 {
00539     Q_D(const QBoxLayout);
00540     return d->list.count();
00541 }

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

Implements QLayout.

Definition at line 584 of file qboxlayout.cpp.

References a, QLayoutItem::alignment(), QLayout::alignmentRect(), QRect::bottom(), BottomToTop, d, QLayout::geometry(), QRect::height(), horz(), i, QBoxLayoutItem::item, j, LeftToRight, m, QLayout::margin(), minimumSize(), n, QObject::parent(), QLayout::parentWidget(), qGeomCalc(), reverse(), QRect::right(), RightToLeft, s, QLayout::setGeometry(), QLayoutItem::setGeometry(), sizeHint(), QLayout::spacing(), TopToBottom, QRect::width(), QRect::x(), and QRect::y().

00585 {
00586     Q_D(QBoxLayout);
00587     if (d->dirty || r != geometry()) {
00588         QRect rect = geometry();
00589         QLayout::setGeometry(r);
00590         if (d->dirty)
00591             d->setupGeom();
00592         QRect cr = alignment() ? alignmentRect(r) : r;
00593         int m = margin();
00594         QRect s(cr.x() + m, cr.y() + m,
00595                  cr.width() - 2 * m, cr.height() - 2 * m);
00596 
00597         QVector<QLayoutStruct> a = d->geomArray;
00598         int pos = horz(d->dir) ? s.x() : s.y();
00599         int space = horz(d->dir) ? s.width() : s.height();
00600         int n = a.count();
00601         if (d->hasHfw && !horz(d->dir)) {
00602             for (int i = 0; i < n; i++) {
00603                 QBoxLayoutItem *box = d->list.at(i);
00604                 if (box->item->hasHeightForWidth())
00605                     a[i].sizeHint = a[i].minimumSize =
00606                                     box->item->heightForWidth(s.width());
00607             }
00608         }
00609 
00610         Direction visualDir = d->dir;
00611         QWidget *parent = parentWidget();
00612         if (parent && parent->isRightToLeft()) {
00613             if (d->dir == LeftToRight)
00614                 visualDir = RightToLeft;
00615             else if (d->dir == RightToLeft)
00616                 visualDir = LeftToRight;
00617         }
00618 
00619         qGeomCalc(a, 0, n, pos, space, spacing());
00620 
00621         bool reverse = (horz(visualDir)
00622                         ? ((r.right() > rect.right()) != (visualDir == RightToLeft))
00623                         : r.bottom() > rect.bottom());
00624         for (int j = 0; j < n; j++) {
00625             int i = reverse ? n-j-1 : j;
00626             QBoxLayoutItem *box = d->list.at(i);
00627 
00628             switch (visualDir) {
00629             case LeftToRight:
00630                 box->item->setGeometry(QRect(a[i].pos, s.y(),
00631                                               a[i].size, s.height()));
00632                 break;
00633             case RightToLeft:
00634                 box->item->setGeometry(QRect(s.left() + s.right()
00635                                               - a[i].pos - a[i].size + 1, s.y(),
00636                                               a[i].size, s.height()));
00637                 break;
00638             case TopToBottom:
00639                 box->item->setGeometry(QRect(s.x(), a[i].pos,
00640                                               s.width(), a[i].size));
00641                 break;
00642             case BottomToTop:
00643                 box->item->setGeometry(QRect(s.x(), s.top() + s.bottom()
00644                                               - a[i].pos - a[i].size + 1,
00645                                               s.width(), a[i].size));
00646             }
00647         }
00648     }
00649 }

Here is the call graph for this function:

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

Inserts item into this box layout at position index. If index is negative, the item is added at the end.

Warning:
Do not call QLayout::insertChildLayout() if item is a QLayout.
See also:
addItem(), insertWidget(), insertLayout(), insertStretch(), insertSpacing()

Definition at line 672 of file qboxlayout.cpp.

References d, and invalidate().

00673 {
00674     Q_D(QBoxLayout);
00675     if (index < 0)                                // append
00676         index = d->list.count();
00677 
00678     QBoxLayoutItem *it = new QBoxLayoutItem(item);
00679     d->list.insert(index, it);
00680     invalidate();
00681 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 16:53:02 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1