TQGridLayout takes the space made available to it (by its parent layout or by the mainWidget()), 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.
.PP
Each column has a minimum width and a stretch factor. The minimum width is the greatest of that set using addColSpacing() and the minimum width of each widget in that column. The stretch factor is set using setColStretch() 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(), addLayout() or by the auto-add facility. It is also possible for a widget to occupy multiple cells using addMultiCellWidget(). If you do this, TQGridLayout will guess how to distribute the size over the columns/rows (based on the stretch factors).
To remove a widget from a layout, call remove(). Calling TQWidget::hide() on a widget also effectively removes the widget from the layout until TQWidget::show() is called.
Columns 0, 2 and 4 in this dialog fragment are made up of a TQLabel, a TQLineEdit, and a TQListBox. Columns 1 and 3 are placeholders made with addColSpacing(). Row 0 consists of three TQLabel objects, row 1 of three TQLineEdit objects and row 2 of three TQListBox 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 addColSpacing() and setColStretch().
If the TQGridLayout 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 parentLayout->addLayout().
Once you have added your layout you can start putting widgets and other layouts into the cells of your grid layout using addWidget(), addLayout() and addMultiCellWidget().
TQGridLayout also includes two margin widths: the border and the spacing. The border is the width of the reserved space along each of the TQGridLayout's four sides. The spacing is the width of the automatically allocated spacing between neighboring boxes.
.SH "TQGridLayout::TQGridLayout ( TQWidget * parent, int nRows = 1, int nCols = 1, int margin = 0, int space = -1, const char * name = 0 )"
Constructs a new TQGridLayout with \fInRows\fR rows, \fInCols\fR columns and parent widget, \fIparent\fR. \fIparent\fR may not be 0. The grid layout is called \fIname\fR.
\fImargin\fR is the number of pixels between the edge of the widget and its managed children. \fIspace\fR is the default number of pixels between cells. If \fIspace\fR is -1, the value of \fImargin\fR is used.
.SH "TQGridLayout::TQGridLayout ( int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )"
Constructs a new grid with \fInRows\fR rows and \fInCols\fR columns. If \fIspacing\fR is -1, this TQGridLayout inherits its parent's spacing(); otherwise \fIspacing\fR is used. The grid layout is called \fIname\fR.
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.
Constructs a new grid that is placed inside \fIparentLayout\fR with \fInRows\fR rows and \fInCols\fR columns. If \fIspacing\fR is -1, this TQGridLayout inherits its parent's spacing(); otherwise \fIspacing\fR is used. The grid layout is called \fIname\fR.
Places the \fIlayout\fR at position (\fIrow\fR, \fIcol\fR) in the grid. The top-left position is (0, 0).
.PP
\fIlayout\fR becomes a child of the grid layout.
.PP
When a layout is constructed with another layout as its parent, you don't need to call addLayout(); the child layout is automatically added to the parent layout as it is constructed.
.PP
See also addMultiCellLayout().
.PP
Examples:
.)l listbox/listbox.cpp, progressbar/progressbar.cpp, t10/main.cpp, and t13/gamebrd.cpp.
The cell will span from \fIfromRow\fR, \fIfromCol\fR to \fItoRow\fR, \fItoCol\fR. Alignment is specified by \fIalignment\fR, which is a bitwise OR of TQt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell.
Adds the layout \fIlayout\fR to the cell grid, spanning multiple rows/columns. The cell will span from \fIfromRow\fR, \fIfromCol\fR to \fItoRow\fR, \fItoCol\fR.
Alignment is specified by \fIalignment\fR, which is a bitwise OR of TQt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell.
Adds the widget \fIw\fR to the cell grid, spanning multiple rows/columns. The cell will span from \fIfromRow\fR, \fIfromCol\fR to \fItoRow\fR, \fItoCol\fR.
Alignment is specified by \fIalignment\fR, which is a bitwise OR of TQt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell.
Alignment is specified by \fIalignment\fR, which is a bitwise OR of TQt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell.
From TQt 3.0, the \fIalignment\fR parameter is interpreted more aggressively than in previous versions of Qt. A non-default alignment now indicates that the widget should not grow to fill the available space, but should be sized according to sizeHint().
Returns the geometry of the cell with row \fIrow\fR and column \fIcol\fR in the grid. Returns an invalid rectangle if \fIrow\fR or \fIcol\fR is outside the grid.
\fBWarning:\fR in the current version of TQt this function does not return valid results until setGeometry() has been called, i.e. after the mainWidget() is visible.
.SH "void TQGridLayout::expand ( int nRows, int nCols )"
Expands this grid so that it will have \fInRows\fR rows and \fInCols\fR columns. Will not shrink the grid. You should not need to call this function because TQGridLayout expands automatically as new items are inserted.
Returns whether this layout can make use of more space than sizeHint(). A value of Vertical or Horizontal means that it wants to grow in only one dimension, whereas \fCBothDirections\fR means that it wants to grow in both dimensions.
Searches for widget \fIw\fR in this layout (not including child layouts). If \fIw\fR is found, it sets \fC<em>row</em>\fR and \fC<em>col</em>\fR to the row and column and returns TRUE; otherwise returns FALSE.
.PP
Note: if a widget spans multiple rows/columns, the top-left cell is returned.