Qt 4.8
Public Types | Public Functions | Protected Functions | List of all members
QBoxLayout Class Reference

The QBoxLayout class lines up child widgets horizontally or vertically. More...

#include <qboxlayout.h>

Inheritance diagram for QBoxLayout:
QLayout QObject QLayoutItem QHBoxLayout QVBoxLayout

Public Types

enum  Direction {
  LeftToRight, RightToLeft, TopToBottom, BottomToTop,
  Down = TopToBottom, Up = BottomToTop
}
 This type is used to determine the direction of a box layout. More...
 
- Public Types inherited from QLayout
enum  SizeConstraint {
  SetDefaultConstraint, SetNoConstraint, SetMinimumSize, SetFixedSize,
  SetMaximumSize, SetMinAndMaxSize
}
 The possible values are: More...
 

Public Functions

void addItem (QLayoutItem *)
 Reimplemented Function More...
 
void addLayout (QLayout *layout, int stretch=0)
 Adds layout to the end of the box, with serial stretch factor stretch. More...
 
void addSpacerItem (QSpacerItem *spacerItem)
 Adds spacerItem to the end of this box layout. More...
 
void addSpacing (int size)
 Adds a non-stretchable space (a QSpacerItem) with size size to the end of this box layout. More...
 
void addStretch (int stretch=0)
 Adds a stretchable space (a QSpacerItem) with zero minimum size and stretch factor stretch to the end of this box layout. More...
 
void addStrut (int)
 Limits the perpendicular dimension of the box (e.g. More...
 
void addWidget (QWidget *, 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. More...
 
int count () const
 Reimplemented Function More...
 
Direction direction () const
 Returns the direction of the box. More...
 
Qt::Orientations expandingDirections () const
 Reimplemented Function More...
 
bool hasHeightForWidth () const
 Reimplemented Function More...
 
int heightForWidth (int) const
 Reimplemented Function More...
 
void insertLayout (int index, QLayout *layout, int stretch=0)
 Inserts layout at position index, with stretch factor stretch. More...
 
void insertSpacerItem (int index, QSpacerItem *spacerItem)
 Inserts spacerItem at position index, with zero minimum size and stretch factor. More...
 
void insertSpacing (int index, int size)
 Inserts a non-stretchable space (a QSpacerItem) at position index, with size size. More...
 
void insertStretch (int index, int stretch=0)
 Inserts a stretchable space (a QSpacerItem) at position index, with zero minimum size and stretch factor stretch. More...
 
void insertWidget (int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=0)
 Inserts widget at position index, with stretch factor stretch and alignment alignment. More...
 
void invalidate ()
 Resets cached information. More...
 
QLayoutItemitemAt (int) const
 Reimplemented Function More...
 
QSize maximumSize () const
 Reimplemented Function More...
 
int minimumHeightForWidth (int) const
 Reimplemented Function More...
 
QSize minimumSize () const
 Reimplemented Function More...
 
 QBoxLayout (Direction, QWidget *parent=0)
 Constructs a new QBoxLayout with direction dir and parent widget parent. More...
 
void setDirection (Direction)
 Sets the direction of this layout to direction. More...
 
void setGeometry (const QRect &)
 Reimplemented Function More...
 
void setSpacing (int spacing)
 Reimplements QLayout::setSpacing(). More...
 
void setStretch (int index, int stretch)
 Sets the stretch factor at position index. More...
 
bool setStretchFactor (QWidget *w, 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. More...
 
bool setStretchFactor (QLayout *l, int stretch)
 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. More...
 
QSize sizeHint () const
 Reimplemented Function More...
 
int spacing () const
 Reimplements QLayout::spacing(). More...
 
int stretch (int index) const
 Returns the stretch factor at position index. More...
 
QLayoutItemtakeAt (int)
 Reimplemented Function More...
 
 ~QBoxLayout ()
 Destroys this box layout. More...
 
- Public Functions inherited from QLayout
bool activate ()
 Redoes the layout for parentWidget() if necessary. More...
 
void addWidget (QWidget *w)
 Adds widget w to this layout in a manner specific to the layout. More...
 
QMargins contentsMargins () const
 Returns the margins used around the layout. More...
 
QRect contentsRect () const
 Returns the layout's geometry() rectangle, but taking into account the contents margins. More...
 
Qt::Orientations expandingDirections () const
 Returns whether this layout can make use of more space than sizeHint(). More...
 
QRect geometry () const
 Reimplemented Function More...
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
virtual int indexOf (QWidget *) const
 Searches for widget widget in this layout (not including child layouts). More...
 
void invalidate ()
 Reimplemented Function More...
 
bool isEmpty () const
 Reimplemented Function More...
 
bool isEnabled () const
 Returns true if the layout is enabled; otherwise returns false. More...
 
QLayoutlayout ()
 Reimplemented Function More...
 
int margin () const
 
QSize maximumSize () const
 Returns the maximum size of this layout. More...
 
QWidgetmenuBar () const
 Returns the menu bar set for this layout, or 0 if no menu bar is set. More...
 
QSize minimumSize () const
 Returns the minimum size of this layout. More...
 
QWidgetparentWidget () const
 Returns the parent widget of this layout, or 0 if this layout is not installed on any widget. More...
 
 QLayout (QWidget *parent)
 Constructs a new top-level QLayout, with parent parent. More...
 
 QLayout ()
 Constructs a new child QLayout. More...
 
void removeItem (QLayoutItem *)
 Removes the layout item item from the layout. More...
 
void removeWidget (QWidget *w)
 Removes the widget widget from the layout. More...
 
bool setAlignment (QWidget *w, Qt::Alignment alignment)
 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. More...
 
bool setAlignment (QLayout *l, Qt::Alignment alignment)
 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. More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the left, top, right, and bottom margins to use around the layout. More...
 
void setContentsMargins (const QMargins &margins)
 Sets the margins to use around the layout. More...
 
void setEnabled (bool)
 Enables this layout if enable is true, otherwise disables it. More...
 
void setMargin (int)
 
void setMenuBar (QWidget *w)
 Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). More...
 
void setSizeConstraint (SizeConstraint)
 
void setSpacing (int)
 
SizeConstraint sizeConstraint () const
 
int spacing () const
 
int totalHeightForWidth (int w) const
 Also takes contentsMargins and menu bar into account. More...
 
QSize totalMaximumSize () const
 Also takes contentsMargins and menu bar into account. More...
 
QSize totalMinimumSize () const
 Also takes contentsMargins and menu bar into account. More...
 
QSize totalSizeHint () const
 Also takes contentsMargins and menu bar into account. More...
 
void update ()
 Updates the layout for parentWidget(). More...
 
 ~QLayout ()
 Destroys the layout, deleting all child layouts. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QLayoutItem
Qt::Alignment alignment () const
 Returns the alignment of this item. More...
 
QSizePolicy::ControlTypes controlTypes () const
 Returns the control type(s) for the layout item. More...
 
 QLayoutItem (Qt::Alignment alignment=0)
 Constructs a layout item with an alignment. More...
 
void setAlignment (Qt::Alignment a)
 Sets the alignment of this item to alignment. More...
 
virtual QSpacerItemspacerItem ()
 If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned. More...
 
virtual QWidgetwidget ()
 If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned. More...
 
virtual ~QLayoutItem ()
 Destroys the QLayoutItem. More...
 

Protected Functions

void insertItem (int index, QLayoutItem *)
 Inserts item into this box layout at position index. More...
 
- Protected Functions inherited from QLayout
void addChildLayout (QLayout *l)
 This function is called from addLayout() or insertLayout() functions in subclasses to add layout l as a sub-layout. More...
 
void addChildWidget (QWidget *w)
 This function is called from addWidget() functions in subclasses to add w as a managed widget of a layout. More...
 
bool adoptLayout (QLayout *layout)
 
QRect alignmentRect (const QRect &) const
 Returns the rectangle that should be covered when the geometry of this layout is set to r, provided that this layout supports setAlignment(). More...
 
void childEvent (QChildEvent *e)
 Reimplemented Function More...
 
 QLayout (QLayoutPrivate &d, QLayout *, QWidget *)
 
void widgetEvent (QEvent *)
 Performs child widget layout when the parent widget is resized. More...
 
- Protected Functions inherited from QObject
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QLayout
static QSize closestAcceptableSize (const QWidget *w, const QSize &s)
 Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is as close as possible to size. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QLayoutItem
Qt::Alignment align
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

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.

qhboxlayout-with-5-children.png
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).

qvboxlayout-with-5-children.png
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:

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 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 Management}

Definition at line 60 of file qboxlayout.h.

Enumerations

◆ 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
Enumerator
LeftToRight 
RightToLeft 
TopToBottom 
BottomToTop 
Down 
Up 

Definition at line 65 of file qboxlayout.h.

Constructors and Destructors

◆ QBoxLayout()

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 558 of file qboxlayout.cpp.

Referenced by QHBoxLayout::QHBoxLayout(), and QVBoxLayout::QVBoxLayout().

559  : QLayout(*new QBoxLayoutPrivate, 0, parent)
560 {
561  Q_D(QBoxLayout);
562  d->dir = dir;
563 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
QLayout()
Constructs a new child QLayout.
Definition: qlayout.cpp:127

◆ ~QBoxLayout()

QBoxLayout::~QBoxLayout ( )

Destroys this box layout.

The layout's widgets aren't destroyed.

Definition at line 632 of file qboxlayout.cpp.

633 {
634  Q_D(QBoxLayout);
635  d->deleteAll(); // must do it before QObject deletes children, so can't be in ~QBoxLayoutPrivate
636 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482

Functions

◆ addItem()

void QBoxLayout::addItem ( QLayoutItem item)
virtual

Reimplemented Function

Implements QLayout.

Definition at line 894 of file qboxlayout.cpp.

Referenced by QCalendarWidgetPrivate::createNavigationBar(), and QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget().

895 {
896  Q_D(QBoxLayout);
897  QBoxLayoutItem *it = new QBoxLayoutItem(item);
898  d->list.append(it);
899  invalidate();
900 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759

◆ addLayout()

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 1140 of file qboxlayout.cpp.

Referenced by QColorDialogPrivate::init(), QPrintPreviewDialogPrivate::init(), QStatusBar::reformat(), and QCoreFuriCuri::timerEvent().

1141 {
1142  insertLayout(-1, layout, stretch);
1143 }
void insertLayout(int index, QLayout *layout, int stretch=0)
Inserts layout at position index, with stretch factor stretch.
int stretch(int index) const
Returns the stretch factor at position index.

◆ addSpacerItem()

void QBoxLayout::addSpacerItem ( QSpacerItem spacerItem)

Adds spacerItem to the end of this box layout.

Since
4.4
See also
addSpacing(), addStretch()

Definition at line 1104 of file qboxlayout.cpp.

1105 {
1106  insertSpacerItem(-1, spacerItem);
1107 }
void insertSpacerItem(int index, QSpacerItem *spacerItem)
Inserts spacerItem at position index, with zero minimum size and stretch factor.
Definition: qboxlayout.cpp:990

◆ addSpacing()

void QBoxLayout::addSpacing ( int  size)

Adds a non-stretchable space (a QSpacerItem) 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(), QSpacerItem

Definition at line 1078 of file qboxlayout.cpp.

Referenced by QColorDialogPrivate::init(), QDialogButtonBoxPrivate::layoutButtons(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), and QStatusBar::reformat().

1079 {
1080  insertSpacing(-1, size);
1081 }
void insertSpacing(int index, int size)
Inserts a non-stretchable space (a QSpacerItem) at position index, with size size.
Definition: qboxlayout.cpp:929

◆ addStretch()

void QBoxLayout::addStretch ( int  stretch = 0)

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

See also
insertStretch(), addItem(), QSpacerItem

Definition at line 1089 of file qboxlayout.cpp.

Referenced by QColorDialogPrivate::init(), QDialogButtonBoxPrivate::layoutButtons(), and QStatusBar::reformat().

1090 {
1091  insertStretch(-1, stretch);
1092 }
void insertStretch(int index, int stretch=0)
Inserts a stretchable space (a QSpacerItem) at position index, with zero minimum size and stretch fac...
Definition: qboxlayout.cpp:960
int stretch(int index) const
Returns the stretch factor at position index.

◆ addStrut()

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 1152 of file qboxlayout.cpp.

Referenced by QStatusBar::reformat().

1153 {
1154  Q_D(QBoxLayout);
1155  QLayoutItem *b;
1156  if (horz(d->dir))
1158  else
1160 
1161  QBoxLayoutItem *it = new QBoxLayoutItem(b);
1162  it->magic = true;
1163  d->list.append(it);
1164  invalidate();
1165 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
static bool horz(QBoxLayout::Direction dir)
Definition: qboxlayout.cpp:149
static QSpacerItem * createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy=QSizePolicy::Minimum, QSizePolicy::Policy vPolicy=QSizePolicy::Minimum)
Definition: qlayout.cpp:198

◆ addWidget()

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 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 1129 of file qboxlayout.cpp.

Referenced by QDialogButtonBoxPrivate::addButtonsToLayout(), QPrintPropertiesDialog::addItemToOptions(), QCalendarTextNavigator::createDateLabel(), QCalendarWidgetPrivate::createNavigationBar(), QInputDialogPrivate::ensureLayout(), QScriptEdit::extraAreaMouseEvent(), QWorkspaceChild::iconWidget(), QColorDialogPrivate::init(), QFontDialogPrivate::init(), QPrintPreviewDialogPrivate::init(), QPrintPreviewWidgetPrivate::init(), QPageSetupDialogPrivate::init(), QDialogButtonBoxPrivate::layoutButtons(), QCalendarWidget::QCalendarWidget(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QMessageBoxDetailsText::QMessageBoxDetailsText(), QPageSetupWidget::QPageSetupWidget(), QPrintPropertiesDialog::QPrintPropertiesDialog(), QScriptBreakpointsWidget::QScriptBreakpointsWidget(), QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(), QScriptDebuggerCodeView::QScriptDebuggerCodeView(), QScriptDebuggerCodeWidget::QScriptDebuggerCodeWidget(), QScriptDebuggerConsoleWidget::QScriptDebuggerConsoleWidget(), QScriptDebuggerLocalsWidget::QScriptDebuggerLocalsWidget(), QScriptDebuggerScriptsWidget::QScriptDebuggerScriptsWidget(), QScriptDebuggerStackWidget::QScriptDebuggerStackWidget(), QScriptDebugOutputWidget::QScriptDebugOutputWidget(), QScriptErrorLogWidget::QScriptErrorLogWidget(), QScriptNewBreakpointWidget::QScriptNewBreakpointWidget(), QStatusBar::reformat(), QCalendarPopup::setCalendarWidget(), QScriptEngineDebugger::standardWindow(), and QCoreFuriCuri::timerEvent().

1130 {
1131  insertWidget(-1, widget, stretch, alignment);
1132 }
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=0)
Inserts widget at position index, with stretch factor stretch and alignment alignment.
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
int stretch(int index) const
Returns the stretch factor at position index.

◆ count()

int QBoxLayout::count ( ) const
virtual

Reimplemented Function

Implements QLayout.

Definition at line 769 of file qboxlayout.cpp.

Referenced by QCalendarWidgetPrivate::createNavigationBar(), QDialogButtonBoxPrivate::layoutButtons(), and QComboBoxPrivateContainer::updateTopBottomMargin().

770 {
771  Q_D(const QBoxLayout);
772  return d->list.count();
773 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482

◆ direction()

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 1308 of file qboxlayout.cpp.

Referenced by setDirection().

1309 {
1310  Q_D(const QBoxLayout);
1311  return d->dir;
1312 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482

◆ expandingDirections()

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

Reimplemented Function

Implements QLayoutItem.

Definition at line 811 of file qboxlayout.cpp.

812 {
813  Q_D(const QBoxLayout);
814  if (d->dirty)
815  const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
816  return d->expanding;
817 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482

◆ hasHeightForWidth()

bool QBoxLayout::hasHeightForWidth ( ) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 717 of file qboxlayout.cpp.

Referenced by heightForWidth().

718 {
719  Q_D(const QBoxLayout);
720  if (d->dirty)
721  const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
722  return d->hasHfw;
723 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482

◆ heightForWidth()

int QBoxLayout::heightForWidth ( int  w) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 728 of file qboxlayout.cpp.

729 {
730  Q_D(const QBoxLayout);
731  if (!hasHeightForWidth())
732  return -1;
733 
734  int left, top, right, bottom;
735  d->effectiveMargins(&left, &top, &right, &bottom);
736 
737  w -= left + right;
738  if (w != d->hfwWidth)
739  const_cast<QBoxLayout*>(this)->d_func()->calcHfw(w);
740 
741  return d->hfwHeight + top + bottom;
742 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
bool hasHeightForWidth() const
Reimplemented Function
Definition: qboxlayout.cpp:717
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ insertItem()

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.

See also
addItem(), insertWidget(), insertLayout(), insertStretch(), insertSpacing()

Definition at line 909 of file qboxlayout.cpp.

910 {
911  Q_D(QBoxLayout);
912  if (index < 0) // append
913  index = d->list.count();
914 
915  QBoxLayoutItem *it = new QBoxLayoutItem(item);
916  d->list.insert(index, it);
917  invalidate();
918 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
quint16 index

◆ insertLayout()

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 1010 of file qboxlayout.cpp.

Referenced by addLayout().

1011 {
1012  Q_D(QBoxLayout);
1013  if (!adoptLayout(layout))
1014  return;
1015  if (index < 0) // append
1016  index = d->list.count();
1017  QBoxLayoutItem *it = new QBoxLayoutItem(layout, stretch);
1018  d->list.insert(index, it);
1019  invalidate();
1020 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
bool adoptLayout(QLayout *layout)
Definition: qlayout.cpp:987
quint16 index
int stretch(int index) const
Returns the stretch factor at position index.

◆ insertSpacerItem()

void QBoxLayout::insertSpacerItem ( int  index,
QSpacerItem spacerItem 
)

Inserts spacerItem at position index, with zero minimum size and stretch factor.

Since
4.4

If index is negative the space is added at the end.

See also
addSpacerItem(), insertStretch(), insertSpacing()

Definition at line 990 of file qboxlayout.cpp.

Referenced by addSpacerItem().

991 {
992  Q_D(QBoxLayout);
993  if (index < 0) // append
994  index = d->list.count();
995 
996  QBoxLayoutItem *it = new QBoxLayoutItem(spacerItem);
997  it->magic = true;
998  d->list.insert(index, it);
999  invalidate();
1000 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
quint16 index

◆ insertSpacing()

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

Inserts a non-stretchable space (a QSpacerItem) 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(), QSpacerItem

Definition at line 929 of file qboxlayout.cpp.

Referenced by addSpacing(), and QComboBoxPrivateContainer::QComboBoxPrivateContainer().

930 {
931  Q_D(QBoxLayout);
932  if (index < 0) // append
933  index = d->list.count();
934 
935  QLayoutItem *b;
936  if (horz(d->dir))
938  else
940 
941  QT_TRY {
942  QBoxLayoutItem *it = new QBoxLayoutItem(b);
943  it->magic = true;
944  d->list.insert(index, it);
945 
946  } QT_CATCH(...) {
947  delete b;
948  QT_RETHROW;
949  }
950  invalidate();
951 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
#define QT_RETHROW
Definition: qglobal.h:1539
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
static bool horz(QBoxLayout::Direction dir)
Definition: qboxlayout.cpp:149
static QSpacerItem * createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy=QSizePolicy::Minimum, QSizePolicy::Policy vPolicy=QSizePolicy::Minimum)
Definition: qlayout.cpp:198
#define QT_CATCH(A)
Definition: qglobal.h:1537
quint16 index
#define QT_TRY
Definition: qglobal.h:1536

◆ insertStretch()

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

Inserts a stretchable space (a QSpacerItem) 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(), QSpacerItem

Definition at line 960 of file qboxlayout.cpp.

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

961 {
962  Q_D(QBoxLayout);
963  if (index < 0) // append
964  index = d->list.count();
965 
966  QLayoutItem *b;
967  if (horz(d->dir))
969  else
971 
973  it->magic = true;
974  d->list.insert(index, it);
975  invalidate();
976 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
static bool horz(QBoxLayout::Direction dir)
Definition: qboxlayout.cpp:149
static QSpacerItem * createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy=QSizePolicy::Minimum, QSizePolicy::Policy vPolicy=QSizePolicy::Minimum)
Definition: qlayout.cpp:198
quint16 index
int stretch(int index) const
Returns the stretch factor at position index.

◆ insertWidget()

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 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 1042 of file qboxlayout.cpp.

Referenced by addWidget(), QComboBoxPrivateContainer::QComboBoxPrivateContainer(), QAbstractScrollAreaPrivate::replaceScrollBar(), and QInputDialogPrivate::setInputWidget().

1044 {
1045  Q_D(QBoxLayout);
1046  if (!checkWidget(this, widget))
1047  return;
1048  addChildWidget(widget);
1049  if (index < 0) // append
1050  index = d->list.count();
1051  QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget);
1052  b->setAlignment(alignment);
1053 
1054  QBoxLayoutItem *it;
1055  QT_TRY{
1056  it = new QBoxLayoutItem(b, stretch);
1057  } QT_CATCH(...) {
1058  delete b;
1059  QT_RETHROW;
1060  }
1061 
1062  QT_TRY{
1063  d->list.insert(index, it);
1064  } QT_CATCH(...) {
1065  delete it;
1066  QT_RETHROW;
1067  }
1068  invalidate();
1069 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
#define QT_RETHROW
Definition: qglobal.h:1539
void setAlignment(Qt::Alignment a)
Sets the alignment of this item to alignment.
static bool checkWidget(QLayout *layout, QWidget *widget)
Definition: qboxlayout.cpp:58
The QWidgetItem class is a layout item that represents a widget.
Definition: qlayoutitem.h:122
#define QT_CATCH(A)
Definition: qglobal.h:1537
static QWidgetItem * createWidgetItem(const QLayout *layout, QWidget *widget)
Definition: qlayout.cpp:190
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
Definition: qlayout.cpp:1045
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
quint16 index
int stretch(int index) const
Returns the stretch factor at position index.
#define QT_TRY
Definition: qglobal.h:1536

◆ invalidate()

void QBoxLayout::invalidate ( )
virtual

Resets cached information.

Reimplemented from QLayoutItem.

Definition at line 759 of file qboxlayout.cpp.

Referenced by addItem(), addStrut(), insertItem(), insertLayout(), insertSpacerItem(), insertSpacing(), insertStretch(), insertWidget(), setDirection(), setSpacing(), setStretch(), setStretchFactor(), takeAt(), and QComboBoxPrivateContainer::updateTopBottomMargin().

760 {
761  Q_D(QBoxLayout);
762  d->setDirty();
764 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
#define Q_D(Class)
Definition: qglobal.h:2482

◆ itemAt()

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

Reimplemented Function

Implements QLayout.

Definition at line 778 of file qboxlayout.cpp.

Referenced by QDialogButtonBoxPrivate::layoutButtons(), and QComboBoxPrivateContainer::updateTopBottomMargin().

779 {
780  Q_D(const QBoxLayout);
781  return index >= 0 && index < d->list.count() ? d->list.at(index)->item : 0;
782 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index

◆ maximumSize()

QSize QBoxLayout::maximumSize ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 699 of file qboxlayout.cpp.

700 {
701  Q_D(const QBoxLayout);
702  if (d->dirty)
703  const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
704 
705  QSize s = d->maxSize.boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX));
706 
711  return s;
712 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
#define Q_D(Class)
Definition: qglobal.h:2482
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
static const int QLAYOUTSIZE_MAX
Definition: qlayoutitem.h:56

◆ minimumHeightForWidth()

int QBoxLayout::minimumHeightForWidth ( int  w) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 747 of file qboxlayout.cpp.

748 {
749  Q_D(const QBoxLayout);
750  (void) heightForWidth(w);
751  int top, bottom;
752  d->effectiveMargins(0, &top, 0, &bottom);
753  return d->hasHfw ? (d->hfwMinHeight + top + bottom) : -1;
754 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
int heightForWidth(int) const
Reimplemented Function
Definition: qboxlayout.cpp:728

◆ minimumSize()

QSize QBoxLayout::minimumSize ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 688 of file qboxlayout.cpp.

689 {
690  Q_D(const QBoxLayout);
691  if (d->dirty)
692  const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
693  return d->minSize;
694 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setDirection()

void QBoxLayout::setDirection ( Direction  direction)

Sets the direction of this layout to direction.

Definition at line 1257 of file qboxlayout.cpp.

1258 {
1259  Q_D(QBoxLayout);
1260  if (d->dir == direction)
1261  return;
1262  if (horz(d->dir) != horz(direction)) {
1263  //swap around the spacers (the "magic" bits)
1264  //#### a bit yucky, knows too much.
1265  //#### probably best to add access functions to spacerItem
1266  //#### or even a QSpacerItem::flip()
1267  for (int i = 0; i < d->list.size(); ++i) {
1268  QBoxLayoutItem *box = d->list.at(i);
1269  if (box->magic) {
1270  QSpacerItem *sp = box->item->spacerItem();
1271  if (sp) {
1272  if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) {
1273  //spacing or strut
1274  QSize s = sp->sizeHint();
1275  sp->changeSize(s.height(), s.width(),
1278 
1279  } else {
1280  //stretch
1281  if (horz(direction))
1284  else
1285  sp->changeSize(0, 0, QSizePolicy::Minimum,
1287  }
1288  }
1289  }
1290  }
1291  }
1292  d->dir = direction;
1293  invalidate();
1294 }
double d
Definition: qnumeric_p.h:62
QSize sizeHint() const
Reimplemented Function
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
Qt::Orientations expandingDirections() const
Reimplemented Function
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QSpacerItem * spacerItem()
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned.
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
int width() const
Returns the width.
Definition: qsize.h:126
The QSpacerItem class provides blank space in a layout.
Definition: qlayoutitem.h:96
static bool horz(QBoxLayout::Direction dir)
Definition: qboxlayout.cpp:149
Direction direction() const
Returns the direction of the box.
int height() const
Returns the height.
Definition: qsize.h:129
QLayoutItem * item
Definition: qboxlayout.cpp:103
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void changeSize(int w, int h, QSizePolicy::Policy hData=QSizePolicy::Minimum, QSizePolicy::Policy vData=QSizePolicy::Minimum)
Changes this spacer item to have preferred width w, preferred height h, horizontal size policy hPolic...

◆ setGeometry()

void QBoxLayout::setGeometry ( const QRect r)
virtual

Reimplemented Function

Reimplemented from QLayout.

Definition at line 822 of file qboxlayout.cpp.

823 {
824  Q_D(QBoxLayout);
825  if (d->dirty || r != geometry()) {
826  QRect oldRect = geometry();
828  if (d->dirty)
829  d->setupGeom();
830  QRect cr = alignment() ? alignmentRect(r) : r;
831 
832  int left, top, right, bottom;
833  d->effectiveMargins(&left, &top, &right, &bottom);
834  QRect s(cr.x() + left, cr.y() + top,
835  cr.width() - (left + right),
836  cr.height() - (top + bottom));
837 
838  QVector<QLayoutStruct> a = d->geomArray;
839  int pos = horz(d->dir) ? s.x() : s.y();
840  int space = horz(d->dir) ? s.width() : s.height();
841  int n = a.count();
842  if (d->hasHfw && !horz(d->dir)) {
843  for (int i = 0; i < n; i++) {
844  QBoxLayoutItem *box = d->list.at(i);
845  if (box->item->hasHeightForWidth()) {
846  int width = qBound(box->item->minimumSize().width(), s.width(), box->item->maximumSize().width());
847  a[i].sizeHint = a[i].minimumSize =
848  box->item->heightForWidth(width);
849  }
850  }
851  }
852 
853  Direction visualDir = d->dir;
855  if (parent && parent->isRightToLeft()) {
856  if (d->dir == LeftToRight)
857  visualDir = RightToLeft;
858  else if (d->dir == RightToLeft)
859  visualDir = LeftToRight;
860  }
861 
862  qGeomCalc(a, 0, n, pos, space);
863 
864  bool reverse = (horz(visualDir)
865  ? ((r.right() > oldRect.right()) != (visualDir == RightToLeft))
866  : r.bottom() > oldRect.bottom());
867  for (int j = 0; j < n; j++) {
868  int i = reverse ? n-j-1 : j;
869  QBoxLayoutItem *box = d->list.at(i);
870 
871  switch (visualDir) {
872  case LeftToRight:
873  box->item->setGeometry(QRect(a.at(i).pos, s.y(), a.at(i).size, s.height()));
874  break;
875  case RightToLeft:
876  box->item->setGeometry(QRect(s.left() + s.right() - a.at(i).pos - a.at(i).size + 1,
877  s.y(), a.at(i).size, s.height()));
878  break;
879  case TopToBottom:
880  box->item->setGeometry(QRect(s.x(), a.at(i).pos, s.width(), a.at(i).size));
881  break;
882  case BottomToTop:
883  box->item->setGeometry(QRect(s.x(),
884  s.top() + s.bottom() - a.at(i).pos - a.at(i).size + 1,
885  s.width(), a.at(i).size));
886  }
887  }
888  }
889 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
static C reverse(const C &l)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
virtual void setGeometry(const QRect &)
Reimplemented Function
Definition: qlayout.cpp:655
long ASN1_INTEGER_get ASN1_INTEGER * a
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
virtual QSize minimumSize() const =0
Implemented in subclasses to return the minimum size of this item.
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
virtual bool hasHeightForWidth() const
Returns true if this layout&#39;s preferred height depends on its width; otherwise returns false...
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
QWidget * parentWidget() const
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget...
Definition: qlayout.cpp:616
int width() const
Returns the width.
Definition: qsize.h:126
static bool horz(QBoxLayout::Direction dir)
Definition: qboxlayout.cpp:149
QRect alignmentRect(const QRect &) const
Returns the rectangle that should be covered when the geometry of this layout is set to r...
Definition: qlayout.cpp:1459
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
virtual void setGeometry(const QRect &)=0
Implemented in subclasses to set this item&#39;s geometry to r.
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
virtual QSize maximumSize() const =0
Implemented in subclasses to return the maximum size of this item.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QLayoutItem * item
Definition: qboxlayout.cpp:103
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
virtual int heightForWidth(int) const
Returns the preferred height for this layout item, given the width w.
bool isRightToLeft() const
Definition: qwidget.h:428
QRect geometry() const
Reimplemented Function
Definition: qlayout.cpp:664
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ setSpacing()

void QBoxLayout::setSpacing ( int  spacing)

◆ setStretch()

void QBoxLayout::setStretch ( int  index,
int  stretch 
)

Sets the stretch factor at position index.

to stretch.

Since
4.5

Definition at line 1228 of file qboxlayout.cpp.

1229 {
1230  Q_D(QBoxLayout);
1231  if (index >= 0 && index < d->list.size()) {
1232  QBoxLayoutItem *box = d->list.at(index);
1233  if (box->stretch != stretch) {
1234  box->stretch = stretch;
1235  invalidate();
1236  }
1237  }
1238 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
quint16 index
int stretch(int index) const
Returns the stretch factor at position index.

◆ setStretchFactor() [1/2]

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 1180 of file qboxlayout.cpp.

1181 {
1182  Q_D(QBoxLayout);
1183  if (!widget)
1184  return false;
1185  for (int i = 0; i < d->list.size(); ++i) {
1186  QBoxLayoutItem *box = d->list.at(i);
1187  if (box->item->widget() == widget) {
1188  box->stretch = stretch;
1189  invalidate();
1190  return true;
1191  }
1192  }
1193  return false;
1194 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
QLayoutItem * item
Definition: qboxlayout.cpp:103
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
int stretch(int index) const
Returns the stretch factor at position index.

◆ setStretchFactor() [2/2]

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

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.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1206 of file qboxlayout.cpp.

1207 {
1208  Q_D(QBoxLayout);
1209  for (int i = 0; i < d->list.size(); ++i) {
1210  QBoxLayoutItem *box = d->list.at(i);
1211  if (box->item->layout() == layout) {
1212  if (box->stretch != stretch) {
1213  box->stretch = stretch;
1214  invalidate();
1215  }
1216  return true;
1217  }
1218  }
1219  return false;
1220 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
QLayoutItem * item
Definition: qboxlayout.cpp:103
QLayout * layout()
Reimplemented Function
int stretch(int index) const
Returns the stretch factor at position index.

◆ sizeHint()

QSize QBoxLayout::sizeHint ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 677 of file qboxlayout.cpp.

678 {
679  Q_D(const QBoxLayout);
680  if (d->dirty)
681  const_cast<QBoxLayout*>(this)->d_func()->setupGeom();
682  return d->sizeHint;
683 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482

◆ spacing()

int QBoxLayout::spacing ( ) const

Reimplements QLayout::spacing().

If the spacing property is valid, that value is returned. Otherwise, a value for the spacing property is computed and returned. Since layout spacing in a widget is style dependent, if the parent is a widget, it queries the style for the (horizontal or vertical) spacing of the layout. Otherwise, the parent is a layout, and it queries the parent layout for the spacing().

See also
QLayout::spacing(), setSpacing()

Definition at line 649 of file qboxlayout.cpp.

Referenced by QColorDialogPrivate::init(), QBoxLayout(), QHBoxLayout::QHBoxLayout(), QVBoxLayout::QVBoxLayout(), and setSpacing().

650 {
651  Q_D(const QBoxLayout);
652  if (d->spacing >=0) {
653  return d->spacing;
654  } else {
655  return qSmartSpacing(this, d->dir == LeftToRight || d->dir == RightToLeft
658  }
659 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)

◆ stretch()

int QBoxLayout::stretch ( int  index) const

Returns the stretch factor at position index.

Since
4.5

Definition at line 1246 of file qboxlayout.cpp.

Referenced by setStretch(), and setStretchFactor().

1247 {
1248  Q_D(const QBoxLayout);
1249  if (index >= 0 && index < d->list.size())
1250  return d->list.at(index)->stretch;
1251  return -1;
1252 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
quint16 index

◆ takeAt()

QLayoutItem * QBoxLayout::takeAt ( int  index)
virtual

Reimplemented Function

Implements QLayout.

Definition at line 787 of file qboxlayout.cpp.

Referenced by QDialogButtonBoxPrivate::layoutButtons().

788 {
789  Q_D(QBoxLayout);
790  if (index < 0 || index >= d->list.count())
791  return 0;
792  QBoxLayoutItem *b = d->list.takeAt(index);
793  QLayoutItem *item = b->item;
794  b->item = 0;
795  delete b;
796 
797  if (QLayout *l = item->layout()) {
798  // sanity check in case the user passed something weird to QObject::setParent()
799  if (l->parent() == this)
800  l->setParent(0);
801  }
802 
803  invalidate();
804  return item;
805 }
double d
Definition: qnumeric_p.h:62
The QBoxLayout class lines up child widgets horizontally or vertically.
Definition: qboxlayout.h:60
#define Q_D(Class)
Definition: qglobal.h:2482
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
void invalidate()
Resets cached information.
Definition: qboxlayout.cpp:759
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition: qlayoutitem.h:64
The QLayout class is the base class of geometry managers.
Definition: qlayout.h:90
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QLayoutItem * item
Definition: qboxlayout.cpp:103
QFactoryLoader * l
quint16 index

The documentation for this class was generated from the following files: