CopperSpice API
1.9.2
|
The QBoxLayout class lines up child widgets horizontally or vertically. More...
Public Types | |
enum | Direction |
Public Types inherited from QLayout | |
enum | SizeConstraint |
Public Methods | |
QBoxLayout (Direction direction, QWidget *parent=nullptr) | |
~QBoxLayout () | |
void | addItem (QLayoutItem *item) override |
void | addLayout (QLayout *layout, int stretch=0) |
void | addSpacerItem (QSpacerItem *spacerItem) |
void | addSpacing (int size) |
void | addStretch (int stretch=0) |
void | addStrut (int size) |
void | addWidget (QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment ()) |
int | count () const override |
Direction | direction () const |
Qt::Orientations | expandingDirections () const override |
bool | hasHeightForWidth () const override |
int | heightForWidth (int width) const override |
void | insertItem (int index, QLayoutItem *item) |
void | insertLayout (int index, QLayout *layout, int stretch=0) |
void | insertSpacerItem (int index, QSpacerItem *spacerItem) |
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=Qt::Alignment ()) |
void | invalidate () override |
QLayoutItem * | itemAt (int index) const override |
QSize | maximumSize () const override |
int | minimumHeightForWidth (int width) const override |
QSize | minimumSize () const override |
void | setDirection (Direction direction) |
void | setGeometry (const QRect &rect) override |
void | setSpacing (int spacing) |
void | setStretch (int index, int stretch) |
bool | setStretchFactor (QLayout *layout, int stretch) |
bool | setStretchFactor (QWidget *widget, int stretch) |
QSize | sizeHint () const override |
int | spacing () const |
int | stretch (int index) const |
QLayoutItem * | takeAt (int index) override |
Public Methods inherited from QLayout | |
QLayout () | |
QLayout (QWidget *parent) | |
bool | activate () |
void | addWidget (QWidget *w) |
QMargins | contentsMargins () const |
QRect | contentsRect () const |
QSizePolicy::ControlTypes | controlTypes () const override |
Qt::Orientations | expandingDirections () const override |
QRect | geometry () const override |
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
virtual int | indexOf (QWidget *widget) const |
void | invalidate () override |
bool | isEmpty () const override |
bool | isEnabled () const |
QLayout * | layout () override |
int | margin () const |
QSize | maximumSize () const override |
QWidget * | menuBar () const |
QSize | minimumSize () const override |
QWidget * | parentWidget () const |
void | removeItem (QLayoutItem *item) |
void | removeWidget (QWidget *widget) |
virtual QLayoutItem * | replaceWidget (QWidget *from, QWidget *to, Qt::FindChildOptions options=Qt::FindChildrenRecursively) |
bool | setAlignment (QLayout *layout, Qt::Alignment alignment) |
void | setAlignment (Qt::Alignment alignment) |
bool | setAlignment (QWidget *widget, Qt::Alignment alignment) |
void | setContentsMargins (const QMargins &margins) |
void | setContentsMargins (int left, int top, int right, int bottom) |
void | setEnabled (bool enable) |
void | setGeometry (const QRect &rect) override |
void | setMargin (int margin) |
void | setMenuBar (QWidget *widget) |
void | setSizeConstraint (SizeConstraint constraint) |
void | setSpacing (int spacing) |
SizeConstraint | sizeConstraint () const |
int | spacing () const |
void | update () |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Public Methods inherited from QLayoutItem | |
QLayoutItem (Qt::Alignment alignment=Qt::Alignment ()) | |
virtual | ~QLayoutItem () |
Qt::Alignment | alignment () const |
void | setAlignment (Qt::Alignment alignment) |
virtual QSpacerItem * | spacerItem () |
virtual QWidget * | widget () |
Additional Inherited Members | |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots inherited from QObject | |
void | deleteLater () |
Static Public Methods inherited from QLayout | |
static QSize | closestAcceptableSize (const QWidget *widget, const QSize &size) |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Methods inherited from QLayout | |
void | addChildLayout (QLayout *layout) |
void | addChildWidget (QWidget *widget) |
QRect | alignmentRect (const QRect &rect) const |
void | childEvent (QChildEvent *event) override |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Properties inherited from QLayout | |
margin | |
sizeConstraint | |
spacing | |
Properties inherited from QObject | |
objectName | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QBoxLayout class arranges child widgets horizontally or vertically. This class controls how the available space from the parent layout or from the parent widget is used.
If the QBoxLayout orientation is specified as Qt::Horizontal the elements are placed in a row with suitable sizes. Each element will be allocated at least its minimum size and at most its maximum size. Any excess space is shared according to the stretch factors of each element.
If the QBoxLayout orientation is specified as Qt::Vertical the elements are placed in a column with suitable sizes. Each element will be allocated at least its minimum size and at most its maximum size. Any excess space is shared according to the stretch factors of each element.
The preferred way to create a QBoxLayout is to use QHBoxLayout or QVBoxLayout, which both inherit from QBoxLayout.
To remove a widget from a layout, call removeWidget(). Calling QWidget::hide() instructs the layout to remove the element so it is not visible. The extra space is distributed to the other elements. When QWidget::show() is called the element is displayed again and the spacing is adjusted.
Elements can be added to the QBoxLayout using one of four methods.
Use insertWidget(), insertSpacing(), insertStretch(), or insertLayout() to insert an element at a specified position in the current layout.
QBoxLayout includes two different types of margins.
The margin default is provided by the style. The default margin most CopperSpice 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.
This enum type is used to determine the direction of a box layout.
Constant | Value | Description |
---|---|---|
QBoxLayout::LeftToRight | 0 | Horizontal from left to right. |
QBoxLayout::RightToLeft | 1 | Horizontal from right to left. |
QBoxLayout::TopToBottom | 2 | Vertical from top to bottom. |
QBoxLayout::BottomToTop | 3 | Vertical from bottom to top. |
Constructs a new QBoxLayout with direction and the given parent.
QBoxLayout::~QBoxLayout | ( | ) |
Destroys this QBoxLayout. The widgets controlled by this layout are not destroyed.
|
overridevirtual |
Implements QLayout::addItem()
void QBoxLayout::addLayout | ( | QLayout * | layout, |
int | stretch = 0 |
||
) |
Adds layout as a child at the end of current layout with a stretch factor of stretch.
void QBoxLayout::addSpacerItem | ( | QSpacerItem * | spacerItem | ) |
Adds spacerItem to the end of the current layout.
void QBoxLayout::addSpacing | ( | int | size | ) |
Adds a non-stretchable space with the given size to the end of the current QBoxLayout. The units for size are in pixels. This method adds additional space beyond the default margin and spacing.
void QBoxLayout::addStretch | ( | int | stretch = 0 | ) |
Adds a stretchable space with zero minimum size and stretch factor stretch to the end of the current QBoxLayout.
void QBoxLayout::addStrut | ( | int | size | ) |
Sets a minimum size for the current QBoxLayout in the direction opposite of the layout. Other constraints may increase the limit.
void QBoxLayout::addWidget | ( | QWidget * | widget, |
int | stretch = 0 , |
||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
Adds the widget to the end of the current QBoxLayout with a stretch factor of stretch and alignment.
The stretch factor applies only in the direction of the QBoxLayout and is relative to the other elements and widgets in the current QBoxLayout. Elements 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 is involved.
The default alignment is 0 which means the widget fills the entire cell.
|
overridevirtual |
Implements QLayout::count()
Direction QBoxLayout::direction | ( | ) | const |
Returns the orientation of the current QBoxLayout.
|
overridevirtual |
Implements QLayoutItem::expandingDirections()
|
overridevirtual |
Reimplemented from QLayoutItem::hasHeightForWidth()
|
overridevirtual |
Reimplemented from QLayoutItem::heightForWidth()
void QBoxLayout::insertItem | ( | int | index, |
QLayoutItem * | item | ||
) |
Inserts item into the current QBoxLayout at position index. If index is negative the item is added at the end of the current layout.
void QBoxLayout::insertLayout | ( | int | index, |
QLayout * | layout, | ||
int | stretch = 0 |
||
) |
Inserts layout into the current QBoxLayout at position index, with a stretch factor of stretch. If index is negative the layout is added at the end of the current QBoxLayout.
void QBoxLayout::insertSpacerItem | ( | int | index, |
QSpacerItem * | spacerItem | ||
) |
Inserts spacerItem into the current QBoxLayout at position index, with zero minimum size and stretch factor. If index is negative the space is added at the end of the current QBoxLayout.
void QBoxLayout::insertSpacing | ( | int | index, |
int | size | ||
) |
Inserts a non-stretchable space into the current QBoxLayout at position index with the given size. If index is negative the space is added at the end of the current QBoxLayout.
void QBoxLayout::insertStretch | ( | int | index, |
int | stretch = 0 |
||
) |
Inserts a stretchable space at position index, with zero minimum size and a stretch factor of stretch. If index is negative the space is added at the end of the current QBoxLayout.
void QBoxLayout::insertWidget | ( | int | index, |
QWidget * | widget, | ||
int | stretch = 0 , |
||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
Inserts widget at position index, with stretch factor of stretch and the given alignment. If index is negative the widget is added at the end of the current QBoxLayout.
The stretch factor applies only in the direction of the QBoxLayout and is relative to the other elements and widgets in the current QBoxLayout. Elements 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 is involved.
The default alignment is 0 which means the widget fills the entire cell.
|
overridevirtual |
Resets cached information.
Reimplemented from QLayoutItem::invalidate()
|
overridevirtual |
Implements QLayout::itemAt()
|
overridevirtual |
Implements QLayoutItem::maximumSize()
|
overridevirtual |
Reimplemented from QLayoutItem::minimumHeightForWidth()
|
overridevirtual |
Implements QLayoutItem::minimumSize()
void QBoxLayout::setDirection | ( | Direction | direction | ) |
Sets the direction of this layout to direction.
|
overridevirtual |
Implements QLayoutItem::setGeometry()
void QBoxLayout::setSpacing | ( | int | spacing | ) |
Sets the spacing property to spacing.
void QBoxLayout::setStretch | ( | int | index, |
int | stretch | ||
) |
Sets the stretch factor at position index to stretch.
bool QBoxLayout::setStretchFactor | ( | QLayout * | layout, |
int | stretch | ||
) |
Sets the stretch factor for the given layout to stretch. Returns true if the layout is found in the current QBoxLayout (not including child layouts), otherwise returns false.
bool QBoxLayout::setStretchFactor | ( | QWidget * | widget, |
int | stretch | ||
) |
Sets the stretch factor for the given widget to stretch. Returns true if the widget is found in the current QBoxLayout (not including child layouts), otherwise returns false.
|
overridevirtual |
Implements QLayoutItem::sizeHint()
int QBoxLayout::spacing | ( | ) | const |
If the spacing property is valid the value is returned. If the value is not valid then the spacing property is computed and returned.
Since layout spacing in a widget is style dependent this method queries the style for the horizontal or vertical spacing of the layout. If the parent is a layout this method queries the parent layout for the spacing.
int QBoxLayout::stretch | ( | int | index | ) | const |
Returns the stretch factor at position index.
|
overridevirtual |
Implements QLayout::takeAt()