![]() |
Qt 6.x
The Qt SDK
|
The QGridLayout class lays out widgets in a grid. More...
#include <qgridlayout.h>
Public Member Functions | |
QGridLayout (QWidget *parent=nullptr) | |
Constructs a new QGridLayout with parent widget, parent. | |
~QGridLayout () | |
Destroys the grid layout. | |
QSize | sizeHint () const override |
\reimp | |
QSize | minimumSize () const override |
\reimp | |
QSize | maximumSize () const override |
\reimp | |
void | setHorizontalSpacing (int spacing) |
int | horizontalSpacing () const |
the spacing between widgets that are laid out side by side | |
void | setVerticalSpacing (int spacing) |
int | verticalSpacing () const |
the spacing between widgets that are laid out on top of each other | |
void | setSpacing (int spacing) override |
This function sets both the vertical and horizontal spacing to spacing. | |
int | spacing () const override |
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it return -1. | |
void | setRowStretch (int row, int stretch) |
Sets the stretch factor of row row to stretch. | |
void | setColumnStretch (int column, int stretch) |
Sets the stretch factor of column column to stretch. | |
int | rowStretch (int row) const |
Returns the stretch factor for row row. | |
int | columnStretch (int column) const |
Returns the stretch factor for column column. | |
void | setRowMinimumHeight (int row, int minSize) |
Sets the minimum height of row row to minSize pixels. | |
void | setColumnMinimumWidth (int column, int minSize) |
Sets the minimum width of column column to minSize pixels. | |
int | rowMinimumHeight (int row) const |
Returns the minimum width set for row row. | |
int | columnMinimumWidth (int column) const |
Returns the column spacing for column column. | |
int | columnCount () const |
Returns the number of columns in this grid. | |
int | rowCount () const |
Returns the number of rows in this grid. | |
QRect | cellRect (int row, int column) const |
Returns the geometry of the cell with row row and column column in the grid. | |
bool | hasHeightForWidth () const override |
\reimp | |
int | heightForWidth (int) const override |
\reimp | |
int | minimumHeightForWidth (int) const override |
\reimp | |
Qt::Orientations | expandingDirections () const override |
\reimp | |
void | invalidate () override |
\reimp | |
void | addWidget (QWidget *w) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | addWidget (QWidget *, int row, int column, Qt::Alignment=Qt::Alignment()) |
Adds the given widget to the cell grid at row, column. | |
void | addWidget (QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment=Qt::Alignment()) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This version adds the given widget to the cell grid, spanning multiple rows/columns. | |
void | addLayout (QLayout *, int row, int column, Qt::Alignment=Qt::Alignment()) |
Places the layout at position (row, column) in the grid. | |
void | addLayout (QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment=Qt::Alignment()) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This version adds the layout layout to the cell grid, spanning multiple rows/columns. | |
void | setOriginCorner (Qt::Corner) |
Sets the grid's origin corner, i.e. | |
Qt::Corner | originCorner () const |
Returns the corner that's used for the grid's origin, i.e. | |
QLayoutItem * | itemAt (int index) const override |
\reimp | |
QLayoutItem * | itemAtPosition (int row, int column) const |
QLayoutItem * | takeAt (int index) override |
\reimp | |
int | count () const override |
\reimp | |
void | setGeometry (const QRect &) override |
\reimp | |
void | addItem (QLayoutItem *item, int row, int column, int rowSpan=1, int columnSpan=1, Qt::Alignment=Qt::Alignment()) |
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it according to alignment. | |
void | setDefaultPositioning (int n, Qt::Orientation orient) |
void | getItemPosition (int idx, int *row, int *column, int *rowSpan, int *columnSpan) const |
Returns the position information of the item with the given index. | |
![]() | |
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) |
SizeConstraint | sizeConstraint () 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. | |
![]() | |
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 | 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. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
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::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), 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 (const QString &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 > | |
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 . | |
![]() | |
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 QSize | minimumSize () const =0 |
Implemented in subclasses to return the minimum size of this item. | |
virtual QSize | maximumSize () const =0 |
Implemented in subclasses to return the maximum size of this item. | |
virtual Qt::Orientations | expandingDirections () const =0 |
Returns whether this layout item can make use of more space than sizeHint(). | |
virtual void | setGeometry (const QRect &)=0 |
Implemented in subclasses to set this item's geometry to r. | |
virtual QRect | geometry () const =0 |
Returns the rectangle covered by this layout item. | |
virtual bool | isEmpty () const =0 |
Implemented in subclasses to return whether this item is empty, i.e. | |
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 void | invalidate () |
Invalidates any cached information in this layout item. | |
virtual QWidget * | widget () const |
If this item manages a QWidget, returns that widget. | |
virtual QLayout * | layout () |
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned. | |
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. | |
virtual QSizePolicy::ControlTypes | controlTypes () const |
Returns the control type(s) for the layout item. | |
Protected Member Functions | |
void | addItem (QLayoutItem *) override |
\reimp | |
![]() | |
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 *) | |
![]() | |
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 | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
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) | |
Additional Inherited Members | |
![]() | |
enum | SizeConstraint { SetDefaultConstraint , SetNoConstraint , SetMinimumSize , SetFixedSize , SetMaximumSize , SetMinAndMaxSize } |
The possible values are: More... | |
![]() | |
void | deleteLater () |
\threadsafe | |
![]() | |
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. | |
![]() | |
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 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) |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
Qt::Alignment | align |
![]() | |
int | spacing |
the spacing between widgets inside the layout | |
QMargins | contentsMargins |
SizeConstraint | sizeConstraint |
the resize mode of the layout | |
![]() | |
QString | objectName |
the name of this object | |
![]() | |
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 QGridLayout class lays out widgets in a grid.
\inmodule QtWidgets
QGridLayout takes the space made available to it (by its parent layout or by the parentWidget()), divides it up into rows and columns, and puts each widget it manages into the correct cell.
Columns and rows behave identically; we will discuss columns, but there are equivalent functions for rows.
Each column has a minimum width and a stretch factor. The minimum width is the greatest of that set using setColumnMinimumWidth() and the minimum width of each widget in that column. The stretch factor is set using setColumnStretch() and determines how much of the available space the column will get over and above its necessary minimum.
Normally, each managed widget or layout is put into a cell of its own using addWidget(). It is also possible for a widget to occupy multiple cells using the row and column spanning overloads of addItem() and addWidget(). If you do this, QGridLayout will guess how to distribute the size over the columns/rows (based on the stretch factors).
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.
This illustration shows a fragment of a dialog with a five-column, three-row grid (the grid is shown overlaid in magenta):
A grid layout
Columns 0, 2 and 4 in this dialog fragment are made up of a QLabel, a QLineEdit, and a QListBox. Columns 1 and 3 are placeholders made with setColumnMinimumWidth(). Row 0 consists of three QLabel objects, row 1 of three QLineEdit objects and row 2 of three QListBox objects. We used placeholder columns (1 and 3) to get the right amount of space between the columns.
Note that the columns and rows are not equally wide or tall. If you want two columns to have the same width, you must set their minimum widths and stretch factors to be the same yourself. You do this using setColumnMinimumWidth() and setColumnStretch().
If the QGridLayout is not the top-level layout (i.e. does not manage all of the widget's area and children), you must add it to its parent layout when you create it, but before you do anything with it. The normal way to add a layout is by calling addLayout() on the parent layout.
Once you have added your layout you can start putting widgets and other layouts into the cells of your grid layout using addWidget(), addItem(), and addLayout().
QGridLayout also includes two margin widths: the \l{getContentsMargins()}{contents margin} and the spacing(). The contents margin is the width of the reserved space along each of the QGridLayout's four sides. The spacing() is the width of the automatically allocated spacing between neighboring boxes.
The default contents margin values are provided by the \l{QStyle::pixelMetric()}{style}. The default value 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.
Definition at line 20 of file qgridlayout.h.
Constructs a new QGridLayout with parent widget, parent.
The layout has one row and one column initially, and will expand when new items are inserted.
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 grid layout into another layout, or set it as a widget's layout using QWidget::setLayout().
Definition at line 1050 of file qgridlayout.cpp.
References d.
QGridLayout::~QGridLayout | ( | ) |
Destroys the grid layout.
Geometry management is terminated if this is a top-level grid.
The layout's widgets aren't destroyed.
Definition at line 1085 of file qgridlayout.cpp.
References d.
|
overrideprotectedvirtual |
void QGridLayout::addItem | ( | QLayoutItem * | item, |
int | row, | ||
int | column, | ||
int | rowSpan = 1 , |
||
int | columnSpan = 1 , |
||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it according to alignment.
If rowSpan and/or columnSpan is -1, then the item will extend to the bottom and/or right edge, respectively. The layout takes ownership of the item.
Definition at line 1382 of file qgridlayout.cpp.
References QLayoutItem::alignment(), d, invalidate(), and item.
Referenced by addItem(), addWidget(), QMainWindowPrivate::init(), and QMessageBoxPrivate::setupLayout().
void QGridLayout::addLayout | ( | QLayout * | layout, |
int | row, | ||
int | column, | ||
int | rowSpan, | ||
int | columnSpan, | ||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This version adds the layout layout to the cell grid, spanning multiple rows/columns.
The cell will start at row, column spanning rowSpan rows and columnSpan columns.
If rowSpan and/or columnSpan is -1, then the layout will extend to the bottom and/or right edge, respectively.
Definition at line 1484 of file qgridlayout.cpp.
References QLayout::adoptLayout(), QLayoutItem::alignment(), d, and QLayout::layout().
void QGridLayout::addLayout | ( | QLayout * | layout, |
int | row, | ||
int | column, | ||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
Places the layout at position (row, column) in the grid.
The top-left position is (0, 0).
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
A non-zero alignment indicates that the layout should not grow to fill the available space but should be sized according to sizeHint().
layout becomes a child of the grid layout.
Definition at line 1463 of file qgridlayout.cpp.
References QLayout::adoptLayout(), QLayoutItem::alignment(), d, and QLayout::layout().
Referenced by QWizardPrivate::recreateLayout().
void QGridLayout::addWidget | ( | QWidget * | widget, |
int | fromRow, | ||
int | fromColumn, | ||
int | rowSpan, | ||
int | columnSpan, | ||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This version adds the given widget to the cell grid, spanning multiple rows/columns.
The cell will start at fromRow, fromColumn spanning rowSpan rows and columnSpan columns. The widget will have the given alignment.
If rowSpan and/or columnSpan is -1, then the widget will extend to the bottom and/or right edge, respectively.
Definition at line 1427 of file qgridlayout.cpp.
References QLayout::addChildWidget(), QLayoutItem::alignment(), d, invalidate(), and QLayoutItem::widget().
void QGridLayout::addWidget | ( | QWidget * | widget, |
int | row, | ||
int | column, | ||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
Adds the given widget to the cell grid at row, column.
The top-left position is (0, 0) by default.
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
Definition at line 1399 of file qgridlayout.cpp.
References QLayout::addChildWidget(), addItem(), QLayoutItem::alignment(), className, QLayoutPrivate::createWidgetItem(), d, QByteArray::data(), metaObject(), QObject::objectName, Q_UNLIKELY, qWarning, QString::toLocal8Bit(), toLocal8Bit(), and QLayoutItem::widget().
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 64 of file qgridlayout.h.
References QLayout::addWidget().
Referenced by ButtonWidget::ButtonWidget(), QtPrivate::QColorShower::QColorShower(), QErrorMessage::QErrorMessage(), QWizardHeader::QWizardHeader(), ScreenWidget::ScreenWidget(), QFontDialogPrivate::init(), QWizardPrivate::recreateLayout(), and QMessageBoxPrivate::setupLayout().
QRect QGridLayout::cellRect | ( | int | row, |
int | column | ||
) | const |
Returns the geometry of the cell with row row and column column in the grid.
Returns an invalid rectangle if row or column is outside the grid.
Definition at line 1355 of file qgridlayout.cpp.
References d.
int QGridLayout::columnCount | ( | ) | const |
Returns the number of columns in this grid.
Definition at line 1188 of file qgridlayout.cpp.
References d.
Referenced by QWizardPrivate::recreateLayout(), and QMessageBoxPrivate::setupLayout().
int QGridLayout::columnMinimumWidth | ( | int | column | ) | const |
Returns the column spacing for column column.
Definition at line 1605 of file qgridlayout.cpp.
References d.
int QGridLayout::columnStretch | ( | int | column | ) | const |
Returns the stretch factor for column column.
Definition at line 1533 of file qgridlayout.cpp.
References d.
|
overridevirtual |
\reimp
Implements QLayout.
Definition at line 1270 of file qgridlayout.cpp.
References d.
Referenced by QWizardPrivate::recreateLayout().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 1614 of file qgridlayout.cpp.
References d, horizontalSpacing(), and verticalSpacing().
void QGridLayout::getItemPosition | ( | int | index, |
int * | row, | ||
int * | column, | ||
int * | rowSpan, | ||
int * | columnSpan | ||
) | const |
Returns the position information of the item with the given index.
The variables passed as row and column are updated with the position of the item in the layout, and the rowSpan and columnSpan variables are updated with the vertical and horizontal spans of the item.
Definition at line 1326 of file qgridlayout.cpp.
References d.
|
overridevirtual |
\reimp
Reimplemented from QLayoutItem.
Definition at line 1242 of file qgridlayout.cpp.
References hasHeightForWidth(), horizontalSpacing(), and verticalSpacing().
Referenced by hasHeightForWidth().
|
overridevirtual |
\reimp
Reimplemented from QLayoutItem.
Definition at line 1250 of file qgridlayout.cpp.
References d, QGridLayoutPrivate::heightForWidth(), horizontalSpacing(), and verticalSpacing().
int QGridLayout::horizontalSpacing | ( | ) | const |
the spacing between widgets that are laid out side by side
If no value is explicitly set, the layout's horizontal spacing is inherited from the parent layout, or from the style settings for the parent widget.
Definition at line 1109 of file qgridlayout.cpp.
References d, QStyle::PM_LayoutHorizontalSpacing, and qSmartSpacing().
Referenced by expandingDirections(), hasHeightForWidth(), heightForWidth(), maximumSize(), minimumHeightForWidth(), minimumSize(), setGeometry(), sizeHint(), and spacing().
|
overridevirtual |
\reimp
Reimplemented from QLayoutItem.
Definition at line 1647 of file qgridlayout.cpp.
References d, and QLayout::invalidate().
Referenced by addItem(), addWidget(), setColumnMinimumWidth(), setColumnStretch(), setHorizontalSpacing(), setRowMinimumHeight(), setRowStretch(), setSpacing(), and setVerticalSpacing().
|
overridevirtual |
QLayoutItem * QGridLayout::itemAtPosition | ( | int | row, |
int | column | ||
) | const |
Returns the layout item that occupies cell (row, column), or \nullptr if the cell is empty.
Definition at line 1294 of file qgridlayout.cpp.
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 1223 of file qgridlayout.cpp.
References Qt::AlignHorizontal_Mask, QLayoutItem::alignment(), Qt::AlignVertical_Mask, d, horizontalSpacing(), QLAYOUTSIZE_MAX, and verticalSpacing().
|
overridevirtual |
\reimp
Reimplemented from QLayoutItem.
Definition at line 1260 of file qgridlayout.cpp.
References d, horizontalSpacing(), QGridLayoutPrivate::minimumHeightForWidth(), and verticalSpacing().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 1210 of file qgridlayout.cpp.
References d, horizontalSpacing(), and verticalSpacing().
Qt::Corner QGridLayout::originCorner | ( | ) | const |
Returns the corner that's used for the grid's origin, i.e.
for position (0, 0).
Definition at line 1634 of file qgridlayout.cpp.
References Qt::BottomLeftCorner, Qt::BottomRightCorner, d, Qt::TopLeftCorner, and Qt::TopRightCorner.
int QGridLayout::rowCount | ( | ) | const |
Returns the number of rows in this grid.
Definition at line 1179 of file qgridlayout.cpp.
References d.
Referenced by QWizardPrivate::recreateLayout(), and QMessageBoxPrivate::setupLayout().
int QGridLayout::rowMinimumHeight | ( | int | row | ) | const |
Returns the minimum width set for row row.
Definition at line 1582 of file qgridlayout.cpp.
References d.
int QGridLayout::rowStretch | ( | int | row | ) | const |
Returns the stretch factor for row row.
Definition at line 1522 of file qgridlayout.cpp.
References d.
void QGridLayout::setColumnMinimumWidth | ( | int | column, |
int | minSize | ||
) |
Sets the minimum width of column column to minSize pixels.
Definition at line 1593 of file qgridlayout.cpp.
References d, and invalidate().
Referenced by QWizardHeader::QWizardHeader(), QFontDialogPrivate::init(), QWizardPrivate::recreateLayout(), and QWizardHeader::setup().
void QGridLayout::setColumnStretch | ( | int | column, |
int | stretch | ||
) |
Sets the stretch factor of column column to stretch.
The first column is number 0.
The stretch factor is relative to the other columns in this grid. Columns with a higher stretch factor take more of the available space.
The default stretch factor is 0. If the stretch factor is 0 and no other column in this table can grow at all, the column may still grow.
An alternative approach is to add spacing using addItem() with a QSpacerItem.
Definition at line 1556 of file qgridlayout.cpp.
References d, and invalidate().
Referenced by QErrorMessage::QErrorMessage(), QWizardHeader::QWizardHeader(), and QFontDialogPrivate::init().
void QGridLayout::setDefaultPositioning | ( | int | n, |
Qt::Orientation | orient | ||
) |
(mostly)
Sets the positioning mode used by addItem(). If orient is Qt::Horizontal, this layout is expanded to n columns, and items will be added columns-first. Otherwise it is expanded to n rows and items will be added rows-first.
Definition at line 1066 of file qgridlayout.cpp.
References d, and Qt::Horizontal.
\reimp
Reimplemented from QLayout.
Definition at line 1336 of file qgridlayout.cpp.
References QLayoutItem::alignment(), QLayout::alignmentRect(), d, QLayout::geometry(), horizontalSpacing(), rect, QLayout::setGeometry(), and verticalSpacing().
void QGridLayout::setHorizontalSpacing | ( | int | spacing | ) |
Definition at line 1102 of file qgridlayout.cpp.
References d, invalidate(), and spacing().
Referenced by QWizardPrivate::recreateLayout(), and QMessageBoxPrivate::setupLayout().
void QGridLayout::setOriginCorner | ( | Qt::Corner | corner | ) |
Sets the grid's origin corner, i.e.
position (0, 0), to corner.
Definition at line 1623 of file qgridlayout.cpp.
References Qt::BottomLeftCorner, Qt::BottomRightCorner, d, and Qt::TopRightCorner.
void QGridLayout::setRowMinimumHeight | ( | int | row, |
int | minSize | ||
) |
Sets the minimum height of row row to minSize pixels.
Definition at line 1570 of file qgridlayout.cpp.
References d, and invalidate().
Referenced by QWizardHeader::QWizardHeader(), QFontDialogPrivate::init(), QWizardPrivate::recreateLayout(), QWizardHeader::setup(), and QMessageBoxPrivate::setupLayout().
void QGridLayout::setRowStretch | ( | int | row, |
int | stretch | ||
) |
Sets the stretch factor of row row to stretch.
The first row is number 0.
The stretch factor is relative to the other rows in this grid. Rows with a higher stretch factor take more of the available space.
The default stretch factor is 0. If the stretch factor is 0 and no other row in this table can grow at all, the row may still grow.
Definition at line 1510 of file qgridlayout.cpp.
References d, and invalidate().
Referenced by QErrorMessage::QErrorMessage(), QWizardHeader::QWizardHeader(), and QMessageBoxPrivate::setupLayout().
|
overridevirtual |
This function sets both the vertical and horizontal spacing to spacing.
Reimplemented from QLayout.
Definition at line 1153 of file qgridlayout.cpp.
References d, invalidate(), and spacing().
Referenced by QWizardHeader::QWizardHeader(), QFontDialogPrivate::init(), and QWizardPrivate::recreateLayout().
void QGridLayout::setVerticalSpacing | ( | int | spacing | ) |
Definition at line 1130 of file qgridlayout.cpp.
References d, invalidate(), and spacing().
Referenced by QWizardPrivate::recreateLayout(), and QMessageBoxPrivate::setupLayout().
|
overridevirtual |
\reimp
Implements QLayoutItem.
Definition at line 1197 of file qgridlayout.cpp.
References d, horizontalSpacing(), and verticalSpacing().
|
overridevirtual |
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it return -1.
Reimplemented from QLayout.
Definition at line 1166 of file qgridlayout.cpp.
References horizontalSpacing(), and verticalSpacing().
Referenced by QtPrivate::QColorShower::QColorShower(), QFontDialogPrivate::init(), setHorizontalSpacing(), setSpacing(), and setVerticalSpacing().
|
overridevirtual |
\reimp
Implements QLayout.
Definition at line 1311 of file qgridlayout.cpp.
References d.
Referenced by QWizardPrivate::recreateLayout().
int QGridLayout::verticalSpacing | ( | ) | const |
the spacing between widgets that are laid out on top of each other
If no value is explicitly set, the layout's vertical spacing is inherited from the parent layout, or from the style settings for the parent widget.
Definition at line 1137 of file qgridlayout.cpp.
References d, QStyle::PM_LayoutVerticalSpacing, and qSmartSpacing().
Referenced by expandingDirections(), hasHeightForWidth(), heightForWidth(), maximumSize(), minimumHeightForWidth(), minimumSize(), setGeometry(), sizeHint(), and spacing().