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

The QGridLayout class lays out widgets in a grid. More...

#include <qgridlayout.h>

Inheritance diagram for QGridLayout:
QLayout QObject QLayoutItem

Public Functions

void addItem (QLayoutItem *item, int row, int column, int rowSpan=1, int columnSpan=1, Qt::Alignment=0)
 Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it according to alignment. More...
 
void addLayout (QLayout *, int row, int column, Qt::Alignment=0)
 Places the layout at position (row, column) in the grid. More...
 
void addLayout (QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment=0)
 This version adds the layout layout to the cell grid, spanning multiple rows/columns. More...
 
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. More...
 
void addWidget (QWidget *, int row, int column, Qt::Alignment=0)
 Adds the given widget to the cell grid at row, column. More...
 
void addWidget (QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment=0)
 This version adds the given widget to the cell grid, spanning multiple rows/columns. More...
 
QRect cellRect (int row, int column) const
 Returns the geometry of the cell with row row and column column in the grid. More...
 
int columnCount () const
 Returns the number of columns in this grid. More...
 
int columnMinimumWidth (int column) const
 Returns the column spacing for column column. More...
 
int columnStretch (int column) const
 Returns the stretch factor for column column. More...
 
int count () const
 Reimplemented Function More...
 
Qt::Orientations expandingDirections () const
 Reimplemented Function More...
 
void getItemPosition (int idx, int *row, int *column, int *rowSpan, int *columnSpan)
 Returns the position information of the item with the given index. More...
 
bool hasHeightForWidth () const
 Reimplemented Function More...
 
int heightForWidth (int) const
 Reimplemented Function More...
 
int horizontalSpacing () const
 the spacing between widgets that are laid out side by side More...
 
void invalidate ()
 Reimplemented Function More...
 
QLayoutItemitemAt (int index) const
 Reimplemented Function More...
 
QLayoutItemitemAtPosition (int row, int column) const
 Returns the layout item that occupies cell (row, column), or 0 if the cell is empty. More...
 
QSize maximumSize () const
 Reimplemented Function More...
 
int minimumHeightForWidth (int) const
 Reimplemented Function More...
 
QSize minimumSize () const
 Reimplemented Function More...
 
Qt::Corner originCorner () const
 Returns the corner that's used for the grid's origin, i.e. More...
 
 QGridLayout (QWidget *parent)
 Constructs a new QGridLayout with parent widget, parent. More...
 
 QGridLayout ()
 Constructs a new grid layout. More...
 
int rowCount () const
 Returns the number of rows in this grid. More...
 
int rowMinimumHeight (int row) const
 Returns the minimum width set for row row. More...
 
int rowStretch (int row) const
 Returns the stretch factor for row row. More...
 
void setColumnMinimumWidth (int column, int minSize)
 Sets the minimum width of column column to minSize pixels. More...
 
void setColumnStretch (int column, int stretch)
 Sets the stretch factor of column column to stretch. More...
 
void setDefaultPositioning (int n, Qt::Orientation orient)
 
void setGeometry (const QRect &)
 Reimplemented Function More...
 
void setHorizontalSpacing (int spacing)
 
void setOriginCorner (Qt::Corner)
 Sets the grid's origin corner, i.e. More...
 
void setRowMinimumHeight (int row, int minSize)
 Sets the minimum height of row row to minSize pixels. More...
 
void setRowStretch (int row, int stretch)
 Sets the stretch factor of row row to stretch. More...
 
void setSpacing (int spacing)
 This function sets both the vertical and horizontal spacing to spacing. More...
 
void setVerticalSpacing (int spacing)
 
QSize sizeHint () const
 Reimplemented Function More...
 
int spacing () const
 If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it return -1. More...
 
QLayoutItemtakeAt (int index)
 Reimplemented Function More...
 
int verticalSpacing () const
 the spacing between widgets that are laid out on top of each other More...
 
 ~QGridLayout ()
 Destroys the grid 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 addItem (QLayoutItem *)
 Reimplemented Function 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 Types inherited from QLayout
enum  SizeConstraint {
  SetDefaultConstraint, SetNoConstraint, SetMinimumSize, SetFixedSize,
  SetMaximumSize, SetMinAndMaxSize
}
 The possible values are: More...
 
- 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 QGridLayout class lays out widgets in a grid.

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

gridlayout.png
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 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 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.

See also
QBoxLayout, QStackedLayout, {Layout Management}, {Basic Layouts Example}

Definition at line 60 of file qgridlayout.h.

Constructors and Destructors

◆ QGridLayout() [1/2]

QGridLayout::QGridLayout ( QWidget parent)
explicit

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.

Definition at line 1065 of file qgridlayout.cpp.

1066  : QLayout(*new QGridLayoutPrivate, 0, parent)
1067 {
1068  Q_D(QGridLayout);
1069  d->expand(1, 1);
1070 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QLayout()
Constructs a new child QLayout.
Definition: qlayout.cpp:127
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ QGridLayout() [2/2]

QGridLayout::QGridLayout ( )

Constructs a new grid layout.

You must insert this grid into another layout. You can insert widgets and layouts into this layout at any time, but laying out will not be performed before this is inserted into another layout.

Definition at line 1079 of file qgridlayout.cpp.

1080  : QLayout(*new QGridLayoutPrivate, 0, 0)
1081 {
1082  Q_D(QGridLayout);
1083  d->expand(1, 1);
1084 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QLayout()
Constructs a new child QLayout.
Definition: qlayout.cpp:127
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ ~QGridLayout()

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 1191 of file qgridlayout.cpp.

1192 {
1193  Q_D(QGridLayout);
1194  d->deleteAll();
1195 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

Functions

◆ addItem() [1/2]

void QGridLayout::addItem ( QLayoutItem item,
int  row,
int  column,
int  rowSpan = 1,
int  columnSpan = 1,
Qt::Alignment  alignment = 0 
)

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.

Warning
Do not use this function to add child layouts or child widget items. Use addLayout() or addWidget() instead.

Definition at line 1539 of file qgridlayout.cpp.

Referenced by addItem(), addWidget(), and QMainWindowPrivate::init().

1540 {
1541  Q_D(QGridLayout);
1542  QGridBox *b = new QGridBox(item);
1543  b->setAlignment(alignment);
1544  d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1);
1545  invalidate();
1546 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setAlignment(Qt::Alignment a)
Definition: qgridlayout.cpp:84
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85

◆ addItem() [2/2]

void QGridLayout::addItem ( QLayoutItem item)
protectedvirtual

Reimplemented Function

Implements QLayout.

Definition at line 1521 of file qgridlayout.cpp.

1522 {
1523  Q_D(QGridLayout);
1524  int r, c;
1525  d->getNextPos(r, c);
1526  addItem(item, r, c);
1527 }
double d
Definition: qnumeric_p.h:62
unsigned char c[8]
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
void addItem(QLayoutItem *item, int row, int column, int rowSpan=1, int columnSpan=1, Qt::Alignment=0)
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it accord...

◆ addLayout() [1/2]

void QGridLayout::addLayout ( QLayout layout,
int  row,
int  column,
Qt::Alignment  alignment = 0 
)

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 1636 of file qgridlayout.cpp.

1637 {
1638  Q_D(QGridLayout);
1639  if (!adoptLayout(layout))
1640  return;
1641  QGridBox *b = new QGridBox(layout);
1642  b->setAlignment(alignment);
1643  d->add(b, row, column);
1644 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setAlignment(Qt::Alignment a)
Definition: qgridlayout.cpp:84
bool adoptLayout(QLayout *layout)
Definition: qlayout.cpp:987
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85

◆ addLayout() [2/2]

void QGridLayout::addLayout ( QLayout layout,
int  row,
int  column,
int  rowSpan,
int  columnSpan,
Qt::Alignment  alignment = 0 
)

This version adds the layout layout to the cell grid, spanning multiple rows/columns.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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 1658 of file qgridlayout.cpp.

1660 {
1661  Q_D(QGridLayout);
1662  if (!adoptLayout(layout))
1663  return;
1664  QGridBox *b = new QGridBox(layout);
1665  b->setAlignment(alignment);
1666  d->add(b, row, (rowSpan < 0) ? -1 : row + rowSpan - 1, column, (columnSpan < 0) ? -1 : column + columnSpan - 1);
1667 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setAlignment(Qt::Alignment a)
Definition: qgridlayout.cpp:84
bool adoptLayout(QLayout *layout)
Definition: qlayout.cpp:987
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85

◆ addWidget() [1/3]

void QGridLayout::addWidget ( QWidget widget)
inline

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

Warning
This function is not part of the public interface.

Definition at line 116 of file qgridlayout.h.

Referenced by QFontDialogPrivate::init(), QMessageBoxPrivate::init(), QBalloonTip::QBalloonTip(), QColorShower::QColorShower(), QErrorMessage::QErrorMessage(), qt_mainwindow_layout(), QMessageBox::setDetailedText(), and QMessageBox::setInformativeText().

116 { QLayout::addWidget(w); }
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
Definition: qlayout.cpp:319

◆ addWidget() [2/3]

void QGridLayout::addWidget ( QWidget widget,
int  row,
int  column,
Qt::Alignment  alignment = 0 
)

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 1570 of file qgridlayout.cpp.

1571 {
1572  if (!checkWidget(this, widget))
1573  return;
1574  if (row < 0 || column < 0) {
1575  qWarning("QGridLayout: Cannot add %s/%s to %s/%s at row %d column %d",
1576  widget->metaObject()->className(), widget->objectName().toLocal8Bit().data(),
1577  metaObject()->className(), objectName().toLocal8Bit().data(), row, column);
1578  return;
1579  }
1580  addChildWidget(widget);
1581  QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget);
1582  addItem(b, row, column, 1, 1, alignment);
1583 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
Q_CORE_EXPORT void qWarning(const char *,...)
The QWidgetItem class is a layout item that represents a widget.
Definition: qlayoutitem.h:122
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
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
static bool checkWidget(QLayout *l, QWidget *w)
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QString objectName() const
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
void addItem(QLayoutItem *item, int row, int column, int rowSpan=1, int columnSpan=1, Qt::Alignment=0)
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it accord...
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ addWidget() [3/3]

void QGridLayout::addWidget ( QWidget widget,
int  fromRow,
int  fromColumn,
int  rowSpan,
int  columnSpan,
Qt::Alignment  alignment = 0 
)

This version adds the given widget to the cell grid, spanning multiple rows/columns.

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

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 1600 of file qgridlayout.cpp.

1602 {
1603  Q_D(QGridLayout);
1604  if (!checkWidget(this, widget))
1605  return;
1606  int toRow = (rowSpan < 0) ? -1 : fromRow + rowSpan - 1;
1607  int toColumn = (columnSpan < 0) ? -1 : fromColumn + columnSpan - 1;
1608  addChildWidget(widget);
1609  QGridBox *b = new QGridBox(this, widget);
1610  b->setAlignment(alignment);
1611  d->add(b, fromRow, toRow, fromColumn, toColumn);
1612  invalidate();
1613 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setAlignment(Qt::Alignment a)
Definition: qgridlayout.cpp:84
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
void invalidate()
Reimplemented Function
static bool checkWidget(QLayout *l, QWidget *w)
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85

◆ cellRect()

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.

Warning
in the current version of Qt this function does not return valid results until setGeometry() has been called, i.e. after the parentWidget() is visible.

Definition at line 1495 of file qgridlayout.cpp.

1496 {
1497  Q_D(const QGridLayout);
1498  return d->cellRect(row, column);
1499 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ columnCount()

int QGridLayout::columnCount ( ) const

Returns the number of columns in this grid.

Definition at line 1300 of file qgridlayout.cpp.

Referenced by QMessageBox::setDetailedText().

1301 {
1302  Q_D(const QGridLayout);
1303  return d->numCols();
1304 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ columnMinimumWidth()

int QGridLayout::columnMinimumWidth ( int  column) const

Returns the column spacing for column column.

See also
setColumnMinimumWidth()

Definition at line 1777 of file qgridlayout.cpp.

1778 {
1779  Q_D(const QGridLayout);
1780  return d->colSpacing(column);
1781 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ columnStretch()

int QGridLayout::columnStretch ( int  column) const

Returns the stretch factor for column column.

See also
setColumnStretch()

Definition at line 1705 of file qgridlayout.cpp.

1706 {
1707  Q_D(const QGridLayout);
1708  return d->colStretch(column);
1709 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ count()

int QGridLayout::count ( ) const
virtual

Reimplemented Function

Implements QLayout.

Definition at line 1407 of file qgridlayout.cpp.

1408 {
1409  Q_D(const QGridLayout);
1410  return d->count();
1411 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ expandingDirections()

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

Reimplemented Function

Implements QLayoutItem.

Definition at line 1786 of file qgridlayout.cpp.

1787 {
1788  Q_D(const QGridLayout);
1789  return d->expandingDirections(horizontalSpacing(), verticalSpacing());
1790 }
double d
Definition: qnumeric_p.h:62
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ getItemPosition()

void QGridLayout::getItemPosition ( int  index,
int *  row,
int *  column,
int *  rowSpan,
int *  columnSpan 
)

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.

See also
itemAtPosition(), itemAt()

Definition at line 1466 of file qgridlayout.cpp.

1467 {
1468  Q_D(QGridLayout);
1469  d->getItemPosition(index, row, column, rowSpan, columnSpan);
1470 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
quint16 index

◆ hasHeightForWidth()

bool QGridLayout::hasHeightForWidth ( ) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 1354 of file qgridlayout.cpp.

1355 {
1356  return ((QGridLayout*)this)->d_func()->hasHeightForWidth(horizontalSpacing(), verticalSpacing());
1357 }
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ heightForWidth()

int QGridLayout::heightForWidth ( int  w) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 1362 of file qgridlayout.cpp.

1363 {
1364  Q_D(const QGridLayout);
1365  QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d);
1366  return dat->heightForWidth(w, horizontalSpacing(), verticalSpacing());
1367 }
double d
Definition: qnumeric_p.h:62
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
int heightForWidth(int width, int hSpacing, int vSpacing)
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ horizontalSpacing()

int QGridLayout::horizontalSpacing ( ) const

the spacing between widgets that are laid out side by side

Since
4.3

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.

See also
verticalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing}

Definition at line 1218 of file qgridlayout.cpp.

Referenced by expandingDirections(), hasHeightForWidth(), heightForWidth(), maximumSize(), minimumHeightForWidth(), minimumSize(), setGeometry(), sizeHint(), and spacing().

1219 {
1220  Q_D(const QGridLayout);
1221  if (d->horizontalSpacing >= 0) {
1222  return d->horizontalSpacing;
1223  } else {
1225  }
1226 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ invalidate()

void QGridLayout::invalidate ( )
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 1819 of file qgridlayout.cpp.

Referenced by addItem(), addWidget(), setColumnMinimumWidth(), setColumnStretch(), setHorizontalSpacing(), setRowMinimumHeight(), setRowStretch(), setSpacing(), and setVerticalSpacing().

1820 {
1821  Q_D(QGridLayout);
1822  d->setDirty();
1824 }
double d
Definition: qnumeric_p.h:62
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ itemAt()

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

Reimplemented Function

Implements QLayout.

Definition at line 1417 of file qgridlayout.cpp.

1418 {
1419  Q_D(const QGridLayout);
1420  return d->itemAt(index);
1421 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
quint16 index

◆ itemAtPosition()

QLayoutItem * QGridLayout::itemAtPosition ( int  row,
int  column 
) const

Returns the layout item that occupies cell (row, column), or 0 if the cell is empty.

Since
4.4
See also
getItemPosition(), indexOf()

Definition at line 1434 of file qgridlayout.cpp.

Referenced by qt_mainwindow_layout().

1435 {
1436  Q_D(const QGridLayout);
1437  int n = d->things.count();
1438  for (int i = 0; i < n; ++i) {
1439  QGridBox *box = d->things.at(i);
1440  if (row >= box->row && row <= box->toRow(d->rr)
1441  && column >= box->col && column <= box->toCol(d->cc)) {
1442  return box->item();
1443  }
1444  }
1445  return 0;
1446 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
QLayoutItem * item()
Definition: qgridlayout.cpp:87

◆ maximumSize()

QSize QGridLayout::maximumSize ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 1335 of file qgridlayout.cpp.

1336 {
1337  Q_D(const QGridLayout);
1338 
1339  QSize s = d->maximumSize(horizontalSpacing(), verticalSpacing());
1340  int left, top, right, bottom;
1341  d->effectiveMargins(&left, &top, &right, &bottom);
1342  s += QSize(left + right, top + bottom);
1348  return s;
1349 }
double d
Definition: qnumeric_p.h:62
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135
#define Q_D(Class)
Definition: qglobal.h:2482
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition: qsize.h:192
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
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
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ minimumHeightForWidth()

int QGridLayout::minimumHeightForWidth ( int  w) const
virtual

Reimplemented Function

Reimplemented from QLayoutItem.

Definition at line 1372 of file qgridlayout.cpp.

1373 {
1374  Q_D(const QGridLayout);
1375  QGridLayoutPrivate *dat = const_cast<QGridLayoutPrivate *>(d);
1377 }
double d
Definition: qnumeric_p.h:62
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
int minimumHeightForWidth(int width, int hSpacing, int vSpacing)
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ minimumSize()

QSize QGridLayout::minimumSize ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 1322 of file qgridlayout.cpp.

1323 {
1324  Q_D(const QGridLayout);
1325  QSize result(d->minimumSize(horizontalSpacing(), verticalSpacing()));
1326  int left, top, right, bottom;
1327  d->effectiveMargins(&left, &top, &right, &bottom);
1328  result += QSize(left + right, top + bottom);
1329  return result;
1330 }
double d
Definition: qnumeric_p.h:62
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ originCorner()

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 1806 of file qgridlayout.cpp.

1807 {
1808  Q_D(const QGridLayout);
1809  if (d->horReversed()) {
1810  return d->verReversed() ? Qt::BottomRightCorner : Qt::TopRightCorner;
1811  } else {
1812  return d->verReversed() ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
1813  }
1814 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ rowCount()

int QGridLayout::rowCount ( ) const

Returns the number of rows in this grid.

Definition at line 1291 of file qgridlayout.cpp.

Referenced by QMessageBox::setDetailedText().

1292 {
1293  Q_D(const QGridLayout);
1294  return d->numRows();
1295 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ rowMinimumHeight()

int QGridLayout::rowMinimumHeight ( int  row) const

Returns the minimum width set for row row.

See also
setRowMinimumHeight()

Definition at line 1754 of file qgridlayout.cpp.

1755 {
1756  Q_D(const QGridLayout);
1757  return d->rowSpacing(row);
1758 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ rowStretch()

int QGridLayout::rowStretch ( int  row) const

Returns the stretch factor for row row.

See also
setRowStretch()

Definition at line 1694 of file qgridlayout.cpp.

1695 {
1696  Q_D(const QGridLayout);
1697  return d->rowStretch(row);
1698 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setColumnMinimumWidth()

void QGridLayout::setColumnMinimumWidth ( int  column,
int  minSize 
)

Sets the minimum width of column column to minSize pixels.

See also
columnMinimumWidth(), setRowMinimumHeight()

Definition at line 1765 of file qgridlayout.cpp.

Referenced by QFontDialogPrivate::init().

1766 {
1767  Q_D(QGridLayout);
1768  d->setColumnMinimumWidth(column, minSize);
1769  invalidate();
1770 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setColumnStretch()

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.

See also
columnStretch(), setRowStretch()

Definition at line 1728 of file qgridlayout.cpp.

Referenced by QFontDialogPrivate::init(), and QErrorMessage::QErrorMessage().

1729 {
1730  Q_D(QGridLayout);
1731  d->setColStretch(column, stretch);
1732  invalidate();
1733 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setDefaultPositioning()

void QGridLayout::setDefaultPositioning ( int  n,
Qt::Orientation  orient 
)
Warning
This function is not part of the public interface. (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 1172 of file qgridlayout.cpp.

1173 {
1174  Q_D(QGridLayout);
1175  if (orient == Qt::Horizontal) {
1176  d->expand(1, n);
1177  d->addVertical = false;
1178  } else {
1179  d->expand(n,1);
1180  d->addVertical = true;
1181  }
1182 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setGeometry()

void QGridLayout::setGeometry ( const QRect rect)
virtual

Reimplemented Function

Reimplemented from QLayout.

Definition at line 1476 of file qgridlayout.cpp.

1477 {
1478  Q_D(QGridLayout);
1479  if (d->isDirty() || rect != geometry()) {
1480  QRect cr = alignment() ? alignmentRect(rect) : rect;
1481  d->distribute(cr, horizontalSpacing(), verticalSpacing());
1482  QLayout::setGeometry(rect);
1483  }
1484 }
double d
Definition: qnumeric_p.h:62
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
virtual void setGeometry(const QRect &)
Reimplemented Function
Definition: qlayout.cpp:655
#define Q_D(Class)
Definition: qglobal.h:2482
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
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Qt::Alignment alignment() const
Returns the alignment of this item.
Definition: qlayoutitem.h:85
QRect geometry() const
Reimplemented Function
Definition: qlayout.cpp:664
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ setHorizontalSpacing()

void QGridLayout::setHorizontalSpacing ( int  spacing)

Definition at line 1211 of file qgridlayout.cpp.

Referenced by QMessageBoxPrivate::init().

1212 {
1213  Q_D(QGridLayout);
1214  d->horizontalSpacing = spacing;
1215  invalidate();
1216 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int spacing() const
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setOriginCorner()

void QGridLayout::setOriginCorner ( Qt::Corner  corner)

Sets the grid's origin corner, i.e.

position (0, 0), to corner.

Definition at line 1795 of file qgridlayout.cpp.

1796 {
1797  Q_D(QGridLayout);
1798  d->setReversed(corner == Qt::BottomLeftCorner || corner == Qt::BottomRightCorner,
1799  corner == Qt::TopRightCorner || corner == Qt::BottomRightCorner);
1800 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setRowMinimumHeight()

void QGridLayout::setRowMinimumHeight ( int  row,
int  minSize 
)

Sets the minimum height of row row to minSize pixels.

See also
rowMinimumHeight(), setColumnMinimumWidth()

Definition at line 1742 of file qgridlayout.cpp.

Referenced by QFontDialogPrivate::init(), and QMessageBoxPrivate::init().

1743 {
1744  Q_D(QGridLayout);
1745  d->setRowMinimumHeight(row, minSize);
1746  invalidate();
1747 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setRowStretch()

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.

See also
rowStretch(), setRowMinimumHeight(), setColumnStretch()

Definition at line 1682 of file qgridlayout.cpp.

Referenced by QMessageBoxPrivate::init(), and QErrorMessage::QErrorMessage().

1683 {
1684  Q_D(QGridLayout);
1685  d->setRowStretch(row, stretch);
1686  invalidate();
1687 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setSpacing()

void QGridLayout::setSpacing ( int  spacing)

This function sets both the vertical and horizontal spacing to spacing.

See also
setVerticalSpacing(), setHorizontalSpacing()

Definition at line 1265 of file qgridlayout.cpp.

Referenced by QFontDialogPrivate::init(), and QGridLayout().

1266 {
1267  Q_D(QGridLayout);
1268  d->horizontalSpacing = d->verticalSpacing = spacing;
1269  invalidate();
1270 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int spacing() const
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ setVerticalSpacing()

void QGridLayout::setVerticalSpacing ( int  spacing)

Definition at line 1242 of file qgridlayout.cpp.

Referenced by QMessageBoxPrivate::init().

1243 {
1244  Q_D(QGridLayout);
1245  d->verticalSpacing = spacing;
1246  invalidate();
1247 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int spacing() const
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwi...
void invalidate()
Reimplemented Function
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

◆ sizeHint()

QSize QGridLayout::sizeHint ( ) const
virtual

Reimplemented Function

Implements QLayoutItem.

Definition at line 1309 of file qgridlayout.cpp.

1310 {
1311  Q_D(const QGridLayout);
1312  QSize result(d->sizeHint(horizontalSpacing(), verticalSpacing()));
1313  int left, top, right, bottom;
1314  d->effectiveMargins(&left, &top, &right, &bottom);
1315  result += QSize(left + right, top + bottom);
1316  return result;
1317 }
double d
Definition: qnumeric_p.h:62
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ spacing()

int QGridLayout::spacing ( ) const

If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it return -1.

See also
setSpacing(), verticalSpacing(), horizontalSpacing()

Definition at line 1278 of file qgridlayout.cpp.

Referenced by QFontDialogPrivate::init(), QColorShower::QColorShower(), QGridLayout(), setHorizontalSpacing(), setSpacing(), and setVerticalSpacing().

1279 {
1280  int hSpacing = horizontalSpacing();
1281  if (hSpacing == verticalSpacing()) {
1282  return hSpacing;
1283  } else {
1284  return -1;
1285  }
1286 }
int horizontalSpacing() const
the spacing between widgets that are laid out side by side
int verticalSpacing() const
the spacing between widgets that are laid out on top of each other

◆ takeAt()

QLayoutItem * QGridLayout::takeAt ( int  index)
virtual

Reimplemented Function

Implements QLayout.

Definition at line 1451 of file qgridlayout.cpp.

1452 {
1453  Q_D(QGridLayout);
1454  return d->takeAt(index);
1455 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
quint16 index

◆ verticalSpacing()

int QGridLayout::verticalSpacing ( ) const

the spacing between widgets that are laid out on top of each other

Since
4.3

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.

See also
horizontalSpacing, QStyle::pixelMetric(), {QStyle::}{PM_LayoutHorizontalSpacing}

Definition at line 1249 of file qgridlayout.cpp.

Referenced by expandingDirections(), hasHeightForWidth(), heightForWidth(), maximumSize(), minimumHeightForWidth(), minimumSize(), setGeometry(), sizeHint(), and spacing().

1250 {
1251  Q_D(const QGridLayout);
1252  if (d->verticalSpacing >= 0) {
1253  return d->verticalSpacing;
1254  } else {
1256  }
1257 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60

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