![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QLayout class is the base class of geometry managers. More...
#include <qlayout.h>
Public Types | |
| enum | SizeConstraint { SetDefaultConstraint , SetNoConstraint , SetMinimumSize , SetFixedSize , SetMaximumSize , SetMinAndMaxSize } |
| Describes how the layout constrains the size of the widget. More... | |
Public Member Functions | |
| QLayout (QWidget *parent=nullptr) | |
| Constructs a new top-level QLayout, with parent parent. | |
| ~QLayout () | |
| virtual int | spacing () const |
| virtual void | setSpacing (int) |
| void | setContentsMargins (int left, int top, int right, int bottom) |
| void | setContentsMargins (const QMargins &margins) |
| void | unsetContentsMargins () |
| void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
| QMargins | contentsMargins () const |
| QRect | contentsRect () const |
| 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. | |
| bool | setAlignment (QLayout *l, Qt::Alignment alignment) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.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. | |
| void | setSizeConstraint (SizeConstraint constraint) |
| SizeConstraint | sizeConstraint () const |
| void | setSizeConstraints (SizeConstraint horizontal, SizeConstraint vertical) |
| void | setHorizontalSizeConstraint (SizeConstraint constraint) |
| SizeConstraint | horizontalSizeConstraint () const |
| void | setVerticalSizeConstraint (SizeConstraint constraint) |
| SizeConstraint | verticalSizeConstraint () const |
| void | setMenuBar (QWidget *w) |
| Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). | |
| QWidget * | menuBar () const |
| Returns the menu bar set for this layout, or \nullptr if no menu bar is set. | |
| QWidget * | parentWidget () const |
| Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget. | |
| void | invalidate () override |
| \reimp | |
| QRect | geometry () const override |
| \reimp | |
| bool | activate () |
| Redoes the layout for parentWidget() if necessary. | |
| void | update () |
| Updates the layout for parentWidget(). | |
| void | addWidget (QWidget *w) |
| Adds widget w to this layout in a manner specific to the layout. | |
| virtual void | addItem (QLayoutItem *)=0 |
| Implemented in subclasses to add an item. | |
| void | removeWidget (QWidget *w) |
| Removes the widget widget from the layout. | |
| void | removeItem (QLayoutItem *) |
| Removes the layout item item from the layout. | |
| Qt::Orientations | expandingDirections () const override |
| Returns whether this layout can make use of more space than sizeHint(). | |
| QSize | minimumSize () const override |
| Returns the minimum size of this layout. | |
| QSize | maximumSize () const override |
| Returns the maximum size of this layout. | |
| virtual void | setGeometry (const QRect &) override |
| \reimp | |
| virtual QLayoutItem * | itemAt (int index) const =0 |
| Must be implemented in subclasses to return the layout item at index. | |
| virtual QLayoutItem * | takeAt (int index)=0 |
| Must be implemented in subclasses to remove the layout item at index from the layout, and return the item. | |
| virtual int | indexOf (const QWidget *) const |
| Searches for widget widget in this layout (not including child layouts). | |
| virtual int | indexOf (const QLayoutItem *) const |
| virtual int | count () const =0 |
| Must be implemented in subclasses to return the number of items in the layout. | |
| bool | isEmpty () const override |
| \reimp | |
| QSizePolicy::ControlTypes | controlTypes () const override |
| \reimp | |
| virtual QLayoutItem * | replaceWidget (QWidget *from, QWidget *to, Qt::FindChildOptions options=Qt::FindChildrenRecursively) |
| int | totalMinimumHeightForWidth (int w) const |
| int | totalHeightForWidth (int w) const |
| QSize | totalMinimumSize () const |
| QSize | totalMaximumSize () const |
| QSize | totalSizeHint () const |
| QLayout * | layout () override |
| \reimp | |
| void | setEnabled (bool) |
| Enables this layout if enable is true, otherwise disables it. | |
| bool | isEnabled () const |
Returns true if the layout is enabled; otherwise returns false. | |
| void | setAlignment (Qt::Alignment a) |
| Sets the alignment of this item to alignment. | |
| Public Member Functions inherited from QObject | |
| Q_INVOKABLE | QObject (QObject *parent=nullptr) |
| Constructs an object with parent object parent. | |
| virtual | ~QObject () |
| Destroys the object, deleting all its child objects. | |
| virtual bool | event (QEvent *event) |
| This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
| virtual bool | eventFilter (QObject *watched, QEvent *event) |
| Filters events if this object has been installed as an event filter for the watched object. | |
| QString | objectName () const |
| Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
| Sets the object's name to name. | |
| void | setObjectName (QAnyStringView name) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| QBindable< QString > | bindableObjectName () |
| bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. | |
| bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false. | |
| bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false. | |
| bool | isQmlObjectType () const |
| Returns whether the object has been created by the QML engine or ownership has been explicitly set via QJSEngine::setObjectOwnership(). | |
| bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false. | |
| bool | blockSignals (bool b) noexcept |
| If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
| QThread * | thread () const |
| Returns the thread in which the object lives. | |
| bool | moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL) |
Changes the thread affinity for this object and its children and returns true on success. | |
| int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
| This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
| int | startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
| void | killTimer (int id) |
| Kills the timer with timer identifier, id. | |
| void | killTimer (Qt::TimerId id) |
| template<typename T> | |
| T | findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
| Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
| template<typename T> | |
| QList< T > | findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) 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. | |
| template<typename T> | |
| T | findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename T> | |
| QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| const QObjectList & | children () const |
| Returns a list of child objects. | |
| void | setParent (QObject *parent) |
| Makes the object a child of parent. | |
| void | installEventFilter (QObject *filterObj) |
| Installs an event filter filterObj on this object. | |
| void | removeEventFilter (QObject *obj) |
| Removes an event filter object obj from this object. | |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
| bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
| bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
| void | dumpObjectTree () const |
| Dumps a tree of children to the debug output. | |
| void | dumpObjectInfo () const |
| Dumps information about signal connections, etc. | |
| bool | setProperty (const char *name, const QVariant &value) |
| Sets the value of the object's name property to value. | |
| bool | setProperty (const char *name, QVariant &&value) |
| QVariant | property (const char *name) const |
| Returns the value of the object's name property. | |
| QList< QByteArray > | dynamicPropertyNames () const |
| QBindingStorage * | bindingStorage () |
| const QBindingStorage * | bindingStorage () const |
| QObject * | parent () const |
| Returns a pointer to the parent object. | |
| 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. | |
| Public Member Functions inherited from QLayoutItem | |
| QLayoutItem (Qt::Alignment alignment=Qt::Alignment()) | |
| Constructs a layout item with an alignment. | |
| virtual | ~QLayoutItem () |
| Destroys the QLayoutItem. | |
| virtual QSize | sizeHint () const =0 |
| Implemented in subclasses to return the preferred size of this item. | |
| virtual bool | hasHeightForWidth () const |
Returns true if this layout's preferred height depends on its width; otherwise returns false. | |
| virtual int | heightForWidth (int) const |
| Returns the preferred height for this layout item, given the width, which is not used in this default implementation. | |
| virtual int | minimumHeightForWidth (int) const |
| Returns the minimum height this widget needs for the given width, w. | |
| virtual QWidget * | widget () const |
| If this item manages a QWidget, returns that widget. | |
| virtual QSpacerItem * | spacerItem () |
| If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise \nullptr is returned. | |
| Qt::Alignment | alignment () const |
| Returns the alignment of this item. | |
| void | setAlignment (Qt::Alignment a) |
| Sets the alignment of this item to alignment. | |
Static Public Member Functions | |
| 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. | |
| Static Public Member Functions inherited from QObject | |
| static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
| \threadsafe | |
| static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
| template<typename Func1, typename Func2> | |
| static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
| template<typename Func1, typename Func2> | |
| static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
| static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
| \threadsafe | |
| static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
| static bool | disconnect (const QMetaObject::Connection &) |
| Disconnect a connection. | |
| template<typename Func1, typename Func2> | |
| static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
| template<typename Func1> | |
| static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
Protected Member Functions | |
| void | widgetEvent (QEvent *) |
| void | childEvent (QChildEvent *e) override |
| \reimp | |
| void | addChildLayout (QLayout *l) |
This function is called from addLayout() or insertLayout() functions in subclasses to add layout childLayout as a sub-layout. | |
| void | addChildWidget (QWidget *w) |
This function is called from addWidget() functions in subclasses to add w as a managed widget of a layout. | |
| 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(). | |
| QLayout (QLayoutPrivate &d, QLayout *, QWidget *) | |
| Protected Member Functions inherited from QObject | |
| QObject * | sender () const |
| Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
| int | senderSignalIndex () const |
| int | receivers (const char *signal) const |
| Returns the number of receivers connected to the signal. | |
| bool | isSignalConnected (const QMetaMethod &signal) const |
| virtual void | timerEvent (QTimerEvent *event) |
| This event handler can be reimplemented in a subclass to receive timer events for the object. | |
| virtual void | customEvent (QEvent *event) |
| This event handler can be reimplemented in a subclass to receive custom events. | |
| virtual void | connectNotify (const QMetaMethod &signal) |
| virtual void | disconnectNotify (const QMetaMethod &signal) |
| QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Properties | |
| int | spacing |
| the spacing between widgets inside the layout | |
| QMargins | contentsMargins |
| the margins used around the layout | |
| SizeConstraint | sizeConstraint |
| the resize mode of the layout. | |
| SizeConstraint | horizontalSizeConstraint |
| The horizontal size constraint. | |
| SizeConstraint | verticalSizeConstraint |
| The vertical size constraint. | |
| Properties inherited from QObject | |
| QString | objectName |
| the name of this object | |
Friends | |
| class | QApplicationPrivate |
| class | QWidget |
Additional Inherited Members | |
| Public Slots inherited from QObject | |
| void | deleteLater () |
| \threadsafe | |
| Signals inherited from QObject | |
| void | destroyed (QObject *=nullptr) |
| This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
| void | objectNameChanged (const QString &objectName, QPrivateSignal) |
| This signal is emitted after the object's name has been changed. | |
| Protected Attributes inherited from QObject | |
| QScopedPointer< QObjectData > | d_ptr |
| Protected Attributes inherited from QLayoutItem | |
| Qt::Alignment | align |
| Related Symbols inherited from QObject | |
| template< class T > T | qobject_cast (const QObject *object) |
| Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
| template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
| template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
| QObjectList | |
| \macro Q_CLASSINFO(Name, Value) | |
The QLayout class is the base class of geometry managers.
\inmodule QtWidgets
This is an abstract base class inherited by the concrete classes QBoxLayout, QGridLayout, QFormLayout, and QStackedLayout.
For users of QLayout subclasses or of QMainWindow there is seldom any need to use the basic functions provided by QLayout, such as setSizeConstraint() or setMenuBar(). See \l{Layout Management} for more information.
To make your own layout manager, implement the functions addItem(), sizeHint(), setGeometry(), itemAt() and takeAt(). You should also implement minimumSize() to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement hasHeightForWidth() and heightForWidth(). See the \l{layouts/flowlayout}{Flow Layout} example for more information about implementing custom layout managers.
Geometry management stops when the layout manager is deleted.
Describes how the layout constrains the size of the widget.
A vertical constraint affects the widget's height, while a horizontal constraint affects its width.
The possible values are:
\value SetDefaultConstraint In the constrained orientation(s), the widget’s minimum extent is set to \l minimumSize(), unless a minimum size has already been set.
\value SetFixedSize In the constrained orientation(s), the widget’s extent is set to \l sizeHint(), and it cannot be resized in that direction.
\value SetMinimumSize In the constrained orientation(s), the widget’s minimum extent is set to \l minimumSize().
\value SetMaximumSize In the constrained orientation(s), the widget’s maximum extent is set to \l maximumSize().
\value SetMinAndMaxSize In the constrained orientation(s), the widget’s minimum extent is set to \l minimumSize(), and the maximum extent is set to \l maximumSize().
\value SetNoConstraint No size constraints are applied to the widget.
| Enumerator | |
|---|---|
| SetDefaultConstraint | |
| SetNoConstraint | |
| SetMinimumSize | |
| SetFixedSize | |
| SetMaximumSize | |
| SetMinAndMaxSize | |
|
explicit |
Constructs a new top-level QLayout, with parent parent.
The layout is set directly as the top-level layout for parent. There can be only one top-level layout for a widget. It is returned by QWidget::layout().
If parent is \nullptr, then you must insert this layout into another layout, or set it as a widget's layout using QWidget::setLayout().
Definition at line 74 of file qlayout.cpp.
| QLayout::~QLayout | ( | ) |
Destroys the layout, deleting all child layouts. Geometry management stops when a top-level layout is deleted.
The layout classes will probably be fatally confused if you delete a sublayout.
Definition at line 688 of file qlayout.cpp.
|
protected |
Definition at line 84 of file qlayout.cpp.
| bool QLayout::activate | ( | ) |
Redoes the layout for parentWidget() if necessary.
You should generally not need to call this because it is automatically called at the most appropriate times. It returns true if the layout was redone.
Definition at line 974 of file qlayout.cpp.
This function is called from addLayout() or insertLayout() functions in subclasses to add layout childLayout as a sub-layout.
The only scenario in which you need to call it directly is if you implement a custom layout that supports nested layouts.
Definition at line 707 of file qlayout.cpp.
This function is called from addWidget() functions in subclasses to add w as a managed widget of a layout.
If w is already managed by a layout, this function will produce a warning, and remove w from that layout. This function must therefore be called before adding w to the layout's data structure.
Definition at line 823 of file qlayout.cpp.
|
pure virtual |
Implemented in subclasses to add an item.
How it is added is specific to each subclass.
This function is not usually called in application code. To add a widget to a layout, use the addWidget() function; to add a child layout, use the addLayout() function provided by the relevant QLayout subclass.
{Note:} The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.
Implemented in CardLayout, CardLayout, QBoxLayout, QDockWidgetLayout, QFormLayout, QGridLayout, QMainWindowLayout, QStackedLayout, and QToolBarLayout.
Adds widget w to this layout in a manner specific to the layout.
This function uses addItem().
Definition at line 177 of file qlayout.cpp.
|
protected |
Definition at line 725 of file qlayout.cpp.
Returns the rectangle that should be covered when the geometry of this layout is set to r, provided that this layout supports setAlignment().
The result is derived from sizeHint() and expandingDirections(). It is never larger than r.
Definition at line 1404 of file qlayout.cpp.
|
overrideprotectedvirtual |
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is as close as possible to size.
Definition at line 1537 of file qlayout.cpp.
| QMargins QLayout::contentsMargins | ( | ) | const |
Returns the margins used around the layout.
By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
Definition at line 368 of file qlayout.cpp.
| QRect QLayout::contentsRect | ( | ) | const |
Returns the layout's geometry() rectangle, but taking into account the contents margins.
Definition at line 383 of file qlayout.cpp.
|
overridevirtual |
|
pure virtual |
Must be implemented in subclasses to return the number of items in the layout.
Implemented in CardLayout, CardLayout, QBoxLayout, QDockWidgetLayout, QFormLayout, QGridLayout, QMainWindowLayout, QStackedLayout, and QToolBarLayout.
|
overridevirtual |
Returns whether this layout can make use of more space than sizeHint().
A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, whereas Qt::Vertical | Qt::Horizontal means that it wants to grow in both dimensions.
The default implementation returns Qt::Horizontal | Qt::Vertical. Subclasses reimplement it to return a meaningful value based on their child widgets's \l{QSizePolicy}{size policies}.
Implements QLayoutItem.
Reimplemented in QToolBarLayout.
Definition at line 923 of file qlayout.cpp.
|
overridevirtual |
| void QLayout::getContentsMargins | ( | int * | left, |
| int * | top, | ||
| int * | right, | ||
| int * | bottom ) const |
For each of left, top, right and bottom that is not \nullptr, stores the size of the margin named in the location the pointer refers to.
By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
Definition at line 338 of file qlayout.cpp.
| QLayout::SizeConstraint QLayout::horizontalSizeConstraint | ( | ) | const |
Definition at line 1365 of file qlayout.cpp.
|
virtual |
Returns the index of layoutItem, or -1 if layoutItem is not found.
Reimplemented in QToolBarLayout.
Definition at line 1259 of file qlayout.cpp.
|
virtual |
Searches for widget widget in this layout (not including child layouts).
Returns the index of widget, or -1 if widget is not found.
The default implementation iterates over all items using itemAt().
Reimplemented in QToolBarLayout.
Definition at line 1240 of file qlayout.cpp.
|
overridevirtual |
\reimp
Reimplemented from QLayoutItem.
Reimplemented in QMainWindowLayout, and QToolBarLayout.
Definition at line 471 of file qlayout.cpp.
|
overridevirtual |
\reimp
Implements QLayoutItem.
Reimplemented in QToolBarLayout.
Definition at line 424 of file qlayout.cpp.
| bool QLayout::isEnabled | ( | ) | const |
Returns true if the layout is enabled; otherwise returns false.
Definition at line 1525 of file qlayout.cpp.
|
pure virtual |
Must be implemented in subclasses to return the layout item at index.
If there is no such item, the function must return \nullptr. Items are numbered consecutively from 0. If an item is deleted, other items will be renumbered.
This function can be used to iterate over a layout. The following code will draw a rectangle for each layout item in the layout structure of the widget.
Implemented in CardLayout, CardLayout, QBoxLayout, QDockWidgetLayout, QFormLayout, QGridLayout, QMainWindowLayout, QStackedLayout, and QToolBarLayout.
|
overridevirtual |
|
overridevirtual |
Returns the maximum size of this layout.
This is the largest size that the layout can have while still respecting the specifications.
The returned value doesn't include the space required by QWidget::setContentsMargins() or menuBar().
The default implementation allows unlimited resizing.
Implements QLayoutItem.
Definition at line 906 of file qlayout.cpp.
| QWidget * QLayout::menuBar | ( | ) | const |
Returns the menu bar set for this layout, or \nullptr if no menu bar is set.
Definition at line 874 of file qlayout.cpp.
|
overridevirtual |
Returns the minimum size of this layout.
This is the smallest size that the layout can have while still respecting the specifications.
The returned value doesn't include the space required by QWidget::setContentsMargins() or menuBar().
The default implementation allows unlimited resizing.
Implements QLayoutItem.
Reimplemented in QMainWindowLayout, QStackedLayout, and QToolBarLayout.
Definition at line 891 of file qlayout.cpp.
| QWidget * QLayout::parentWidget | ( | ) | const |
Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget.
If the layout is a sub-layout, this function returns the parent widget of the parent layout.
Definition at line 401 of file qlayout.cpp.
| void QLayout::removeItem | ( | QLayoutItem * | item | ) |
Removes the layout item item from the layout.
It is the caller's responsibility to delete the item.
Notice that item can be a layout (since QLayout inherits QLayoutItem).
Definition at line 1490 of file qlayout.cpp.
Removes the widget widget from the layout.
After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout or to explicitly hide it if necessary.
{Note:} The ownership of widget remains the same as when it was added.
Definition at line 1462 of file qlayout.cpp.
|
virtual |
Searches for widget from and replaces it with widget to if found. Returns the layout item that contains the widget from on success. Otherwise \nullptr is returned. If options contains Qt::FindChildrenRecursively (the default), sub-layouts are searched for doing the replacement. Any other flag in options is ignored.
Notice that the returned item therefore might not belong to this layout, but to a sub-layout.
The returned layout item is no longer owned by the layout and should be either deleted or inserted to another layout. The widget from is no longer managed by the layout and may need to be deleted or hidden. The parent of widget from is left unchanged.
This function works for the built-in Qt layouts, but might not work for custom layouts.
Definition at line 1153 of file qlayout.cpp.
| bool QLayout::setAlignment | ( | QLayout * | l, |
| Qt::Alignment | alignment ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.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.
Definition at line 213 of file qlayout.cpp.
| void QLayoutItem::setAlignment | ( | Qt::Alignment | alignment | ) |
Sets the alignment of this item to alignment.
{Note:} Item alignment is only supported by QLayoutItem subclasses where it would have a visual effect. Except for QSpacerItem, which provides blank space for layouts, all public Qt classes that inherit QLayoutItem support item alignment.
Definition at line 47 of file qlayoutitem.cpp.
| bool QLayout::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.
Definition at line 190 of file qlayout.cpp.
Sets the margins to use around the layout.
By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
Definition at line 304 of file qlayout.cpp.
| void QLayout::setContentsMargins | ( | int | left, |
| int | top, | ||
| int | right, | ||
| int | bottom ) |
Sets the left, top, right, and bottom margins to use around the layout.
By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
Definition at line 279 of file qlayout.cpp.
| void QLayout::setEnabled | ( | bool | enable | ) |
Enables this layout if enable is true, otherwise disables it.
An enabled layout adjusts dynamically to changes; a disabled layout acts as if it did not exist.
By default all layouts are enabled.
Definition at line 1514 of file qlayout.cpp.
\reimp
Implements QLayoutItem.
Reimplemented in CardLayout, CardLayout, QBoxLayout, QDockWidgetLayout, QFormLayout, QGridLayout, QMainWindowLayout, QStackedLayout, and QToolBarLayout.
Definition at line 453 of file qlayout.cpp.
| void QLayout::setHorizontalSizeConstraint | ( | SizeConstraint | constraint | ) |
Definition at line 1355 of file qlayout.cpp.
Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins().
All child widgets are placed below the bottom edge of the menu bar.
Definition at line 861 of file qlayout.cpp.
| void QLayout::setSizeConstraint | ( | SizeConstraint | constraint | ) |
Definition at line 1317 of file qlayout.cpp.
| void QLayout::setSizeConstraints | ( | SizeConstraint | horizontal, |
| SizeConstraint | vertical ) |
Sets both the horizontal and vertical size constraints.
Definition at line 1329 of file qlayout.cpp.
|
virtual |
Reimplemented in QBoxLayout, QFormLayout, and QGridLayout.
Definition at line 257 of file qlayout.cpp.
| void QLayout::setVerticalSizeConstraint | ( | SizeConstraint | constraint | ) |
Definition at line 1381 of file qlayout.cpp.
| QLayout::SizeConstraint QLayout::sizeConstraint | ( | ) | const |
Definition at line 1339 of file qlayout.cpp.
|
virtual |
Reimplemented in QBoxLayout, QFormLayout, and QGridLayout.
Definition at line 246 of file qlayout.cpp.
|
pure virtual |
Must be implemented in subclasses to remove the layout item at index from the layout, and return the item.
If there is no such item, the function must do nothing and return 0. Items are numbered consecutively from 0. If an item is removed, other items will be renumbered.
The following code fragment shows a safe way to remove all items from a layout:
Implemented in CardLayout, CardLayout, QBoxLayout, QDockWidgetLayout, QFormLayout, QGridLayout, QMainWindowLayout, QStackedLayout, and QToolBarLayout.
| int QLayout::totalHeightForWidth | ( | int | w | ) | const |
Also takes contentsMargins and menu bar into account.
Definition at line 595 of file qlayout.cpp.
| QSize QLayout::totalMaximumSize | ( | ) | const |
Also takes contentsMargins and menu bar into account.
Definition at line 659 of file qlayout.cpp.
| int QLayout::totalMinimumHeightForWidth | ( | int | w | ) | const |
Also takes contentsMargins and menu bar into account.
Definition at line 575 of file qlayout.cpp.
| QSize QLayout::totalMinimumSize | ( | ) | const |
Also takes contentsMargins and menu bar into account.
Definition at line 615 of file qlayout.cpp.
| QSize QLayout::totalSizeHint | ( | ) | const |
Also takes contentsMargins and menu bar into account.
Definition at line 636 of file qlayout.cpp.
| void QLayout::unsetContentsMargins | ( | ) |
Unsets any user-defined margins around the layout. The layout will use the default values provided by the style.
Definition at line 317 of file qlayout.cpp.
| void QLayout::update | ( | ) |
Updates the layout for parentWidget().
You should generally not need to call this because it is automatically called at the most appropriate times.
Definition at line 950 of file qlayout.cpp.
| QLayout::SizeConstraint QLayout::verticalSizeConstraint | ( | ) | const |
Definition at line 1390 of file qlayout.cpp.
Performs child widget layout when the parent widget is resized. Also handles removal of widgets. e is the event
Definition at line 520 of file qlayout.cpp.
|
friend |
|
readwrite |
the margins used around the layout
By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.
|
readwrite |
The horizontal size constraint.
The default mode is \l {QLayout::SetDefaultConstraint}
|
readwrite |
the resize mode of the layout.
Setting the size constraint for the dialog. Setting a vertical or horizontal size constraint will override this.
The default mode is \l {QLayout::SetDefaultConstraint} {SetDefaultConstraint}.
|
readwrite |
the spacing between widgets inside the layout
If no value is explicitly set, the layout's spacing is inherited from the parent layout, or from the style settings for the parent widget.
For QGridLayout and QFormLayout, it is possible to set different horizontal and vertical spacings using \l{QGridLayout::}{setHorizontalSpacing()} and \l{QGridLayout::}{setVerticalSpacing()}. In that case, spacing() returns -1.
|
readwrite |