1QGridLayout(3qt)                                              QGridLayout(3qt)
2
3
4

NAME

6       QGridLayout - Lays out widgets in a grid
7

SYNOPSIS

9       #include <qlayout.h>
10
11       Inherits QLayout.
12
13   Public Members
14       QGridLayout ( QWidget * parent, int nRows = 1, int nCols = 1, int
15           margin = 0, int space = -1, const char * name = 0 )
16       QGridLayout ( int nRows = 1, int nCols = 1, int spacing = -1, const
17           char * name = 0 )
18       QGridLayout ( QLayout * parentLayout, int nRows = 1, int nCols = 1, int
19           spacing = -1, const char * name = 0 )
20       ~QGridLayout ()
21       virtual QSize sizeHint () const
22       virtual QSize minimumSize () const
23       virtual QSize maximumSize () const
24       virtual void setRowStretch ( int row, int stretch )
25       virtual void setColStretch ( int col, int stretch )
26       int rowStretch ( int row ) const
27       int colStretch ( int col ) const
28       void setRowSpacing ( int row, int minSize )
29       void setColSpacing ( int col, int minSize )
30       int rowSpacing ( int row ) const
31       int colSpacing ( int col ) const
32       int numRows () const
33       int numCols () const
34       QRect cellGeometry ( int row, int col ) const
35       virtual bool hasHeightForWidth () const
36       virtual int heightForWidth ( int w ) const
37       virtual QSizePolicy::ExpandData expanding () const
38       virtual void invalidate ()
39       virtual void addItem ( QLayoutItem * item )
40       void addItem ( QLayoutItem * item, int row, int col )
41       void addMultiCell ( QLayoutItem * item, int fromRow, int toRow, int
42           fromCol, int toCol, int alignment = 0 )
43       void addWidget ( QWidget * w, int row, int col, int alignment = 0 )
44       void addMultiCellWidget ( QWidget * w, int fromRow, int toRow, int
45           fromCol, int toCol, int alignment = 0 )
46       void addLayout ( QLayout * layout, int row, int col )
47       void addMultiCellLayout ( QLayout * layout, int fromRow, int toRow, int
48           fromCol, int toCol, int alignment = 0 )
49       void addRowSpacing ( int row, int minsize )  (obsolete)
50       void addColSpacing ( int col, int minsize )  (obsolete)
51       void expand ( int nRows, int nCols )
52       enum Corner { TopLeft, TopRight, BottomLeft, BottomRight }
53       void setOrigin ( Corner c )
54       Corner origin () const
55       virtual void setGeometry ( const QRect & r )
56
57   Protected Members
58       bool findWidget ( QWidget * w, int * row, int * col )
59       void add ( QLayoutItem * item, int row, int col )
60

DESCRIPTION

62       The QGridLayout class lays out widgets in a grid.
63
64       QGridLayout takes the space made available to it (by its parent layout
65       or by the mainWidget()), divides it up into rows and columns, and puts
66       each widget it manages into the correct cell.
67
68       Columns and rows behave identically; we will discuss columns, but there
69       are equivalent functions for rows.
70
71       Each column has a minimum width and a stretch factor. The minimum width
72       is the greatest of that set using addColSpacing() and the minimum width
73       of each widget in that column. The stretch factor is set using
74       setColStretch() and determines how much of the available space the
75       column will get over and above its necessary minimum.
76
77       Normally, each managed widget or layout is put into a cell of its own
78       using addWidget(), addLayout() or by the auto-add facility. It is also
79       possible for a widget to occupy multiple cells using
80       addMultiCellWidget(). If you do this, QGridLayout will guess how to
81       distribute the size over the columns/rows (based on the stretch
82       factors).
83
84       To remove a widget from a layout, call remove(). Calling
85       QWidget::hide() on a widget also effectively removes the widget from
86       the layout until QWidget::show() is called.
87
88       This illustration shows a fragment of a dialog with a five-column,
89       three-row grid (the grid is shown overlaid in magenta):
90
91       <center>
92                                   [Image Omitted]
93
94       </center>
95
96       Columns 0, 2 and 4 in this dialog fragment are made up of a QLabel, a
97       QLineEdit, and a QListBox. Columns 1 and 3 are placeholders made with
98       addColSpacing(). Row 0 consists of three QLabel objects, row 1 of three
99       QLineEdit objects and row 2 of three QListBox objects. We used
100       placeholder columns (1 and 3) to get the right amount of space between
101       the columns.
102
103       Note that the columns and rows are not equally wide or tall. If you
104       want two columns to have the same width, you must set their minimum
105       widths and stretch factors to be the same yourself. You do this using
106       addColSpacing() and setColStretch().
107
108       If the QGridLayout is not the top-level layout (i.e. does not manage
109       all of the widget's area and children), you must add it to its parent
110       layout when you create it, but before you do anything with it. The
111       normal way to add a layout is by calling parentLayout->addLayout().
112
113       Once you have added your layout you can start putting widgets and other
114       layouts into the cells of your grid layout using addWidget(),
115       addLayout() and addMultiCellWidget().
116
117       QGridLayout also includes two margin widths: the border and the
118       spacing. The border is the width of the reserved space along each of
119       the QGridLayout's four sides. The spacing is the width of the
120       automatically allocated spacing between neighboring boxes.
121
122       Both the border and the spacing are parameters of the constructor and
123       default to 0.
124
125       See also QGrid, Layout Overview, Widget Appearance and Style, and
126       Layout Management.
127
128   Member Type Documentation

QGridLayout::Corner

130       This enum identifies which corner is the origin (0, 0) of the layout.
131
132       QGridLayout::TopLeft - the top-left corner
133
134       QGridLayout::TopRight - the top-right corner
135
136       QGridLayout::BottomLeft - the bottom-left corner
137
138       QGridLayout::BottomRight - the bottom-right corner
139

MEMBER FUNCTION DOCUMENTATION

QGridLayout::QGridLayout ( QWidget * parent, int nRows = 1, int nCols = 1, int

142       margin = 0, int space = -1, const char * name = 0 )
143       Constructs a new QGridLayout with nRows rows, nCols columns and parent
144       widget, parent. parent may not be 0. The grid layout is called name.
145
146       margin is the number of pixels between the edge of the widget and its
147       managed children. space is the default number of pixels between cells.
148       If space is -1, the value of margin is used.
149

QGridLayout::QGridLayout ( int nRows = 1, int nCols = 1, int spacing = -1,

151       const char * name = 0 )
152       Constructs a new grid with nRows rows and nCols columns. If spacing is
153       -1, this QGridLayout inherits its parent's spacing(); otherwise spacing
154       is used. The grid layout is called name.
155
156       You must insert this grid into another layout. You can insert widgets
157       and layouts into this layout at any time, but laying out will not be
158       performed before this is inserted into another layout.
159

QGridLayout::QGridLayout ( QLayout * parentLayout, int nRows = 1, int nCols =

161       1, int spacing = -1, const char * name = 0 )
162       Constructs a new grid that is placed inside parentLayout with nRows
163       rows and nCols columns. If spacing is -1, this QGridLayout inherits its
164       parent's spacing(); otherwise spacing is used. The grid layout is
165       called name.
166
167       This grid is placed according to parentLayout's default placement
168       rules.
169

QGridLayout::~QGridLayout ()

171       Destroys the grid layout. Geometry management is terminated if this is
172       a top-level grid.
173
174       The layout's widgets aren't destroyed.
175

void QGridLayout::add ( QLayoutItem * item, int row, int col ) [protected]

177       Adds item at position row, col. The layout takes ownership of the item.
178

void QGridLayout::addColSpacing ( int col, int minsize )

180       This function is obsolete. It is provided to keep old source working.
181       We strongly advise against using it in new code.
182
183       Sets the minimum width of column col to minsize pixels.
184
185       Use setColSpacing() instead.
186

void QGridLayout::addItem ( QLayoutItem * item, int row, int col )

188       Adds item at position row, col. The layout takes ownership of the item.
189

void QGridLayout::addItem ( QLayoutItem * item ) [virtual]

191       This is an overloaded member function, provided for convenience. It
192       behaves essentially like the above function.
193
194       Adds item to the next free position of this layout.
195
196       Reimplemented from QLayout.
197

void QGridLayout::addLayout ( QLayout * layout, int row, int col )

199       Places the layout at position (row, col) in the grid. The top-left
200       position is (0, 0).
201
202       layout becomes a child of the grid layout.
203
204       When a layout is constructed with another layout as its parent, you
205       don't need to call addLayout(); the child layout is automatically added
206       to the parent layout as it is constructed.
207
208       See also addMultiCellLayout().
209
210       Examples:
211

void QGridLayout::addMultiCell ( QLayoutItem * item, int fromRow, int toRow,

213       int fromCol, int toCol, int alignment = 0 )
214       Adds the item to the cell grid, spanning multiple rows/columns.
215
216       The cell will span from fromRow, fromCol to toRow, toCol. Alignment is
217       specified by alignment, which is a bitwise OR of Qt::AlignmentFlags
218       values. The default alignment is 0, which means that the widget fills
219       the entire cell.
220

void QGridLayout::addMultiCellLayout ( QLayout * layout, int fromRow, int

222       toRow, int fromCol, int toCol, int alignment = 0 )
223       Adds the layout layout to the cell grid, spanning multiple
224       rows/columns. The cell will span from fromRow, fromCol to toRow, toCol.
225
226       Alignment is specified by alignment, which is a bitwise OR of
227       Qt::AlignmentFlags values. The default alignment is 0, which means that
228       the widget fills the entire cell.
229
230       A non-zero alignment indicates that the layout should not grow to fill
231       the available space but should be sized according to sizeHint().
232
233       layout becomes a child of the grid layout.
234
235       See also addLayout().
236

void QGridLayout::addMultiCellWidget ( QWidget * w, int fromRow, int toRow,

238       int fromCol, int toCol, int alignment = 0 )
239       Adds the widget w to the cell grid, spanning multiple rows/columns. The
240       cell will span from fromRow, fromCol to toRow, toCol.
241
242       Alignment is specified by alignment, which is a bitwise OR of
243       Qt::AlignmentFlags values. The default alignment is 0, which means that
244       the widget fills the entire cell.
245
246       A non-zero alignment indicates that the widget should not grow to fill
247       the available space but should be sized according to sizeHint().
248
249       See also addWidget().
250
251       Examples:
252

void QGridLayout::addRowSpacing ( int row, int minsize )

254       This function is obsolete. It is provided to keep old source working.
255       We strongly advise against using it in new code.
256
257       Sets the minimum height of row row to minsize pixels.
258
259       Use setRowSpacing() instead.
260

void QGridLayout::addWidget ( QWidget * w, int row, int col, int alignment = 0

262       )
263       Adds the widget w to the cell grid at row, col. The top-left position
264       is (0, 0) by default.
265
266       Alignment is specified by alignment, which is a bitwise OR of
267       Qt::AlignmentFlags values. The default alignment is 0, which means that
268       the widget fills the entire cell.
269
270       You should not call this if you have enabled the auto-add facility of
271       the layout.
272
273       From Qt 3.0, the alignment parameter is interpreted more aggressively
274       than in previous versions of Qt. A non-default alignment now indicates
275       that the widget should not grow to fill the available space, but should
276       be sized according to sizeHint().
277
278       See also addMultiCellWidget().
279
280       Examples:
281

QRect QGridLayout::cellGeometry ( int row, int col ) const

283       Returns the geometry of the cell with row row and column col in the
284       grid. Returns an invalid rectangle if row or col is outside the grid.
285
286       Warning: in the current version of Qt this function does not return
287       valid results until setGeometry() has been called, i.e. after the
288       mainWidget() is visible.
289

int QGridLayout::colSpacing ( int col ) const

291       Returns the column spacing for column col.
292
293       See also setColSpacing().
294

int QGridLayout::colStretch ( int col ) const

296       Returns the stretch factor for column col.
297
298       See also setColStretch().
299

void QGridLayout::expand ( int nRows, int nCols )

301       Expands this grid so that it will have nRows rows and nCols columns.
302       Will not shrink the grid. You should not need to call this function
303       because QGridLayout expands automatically as new items are inserted.
304

QSizePolicy::ExpandData QGridLayout::expanding () const [virtual]

306       Returns whether this layout can make use of more space than sizeHint().
307       A value of Vertical or Horizontal means that it wants to grow in only
308       one dimension, whereas BothDirections means that it wants to grow in
309       both dimensions.
310
311       Reimplemented from QLayout.
312

bool QGridLayout::findWidget ( QWidget * w, int * row, int * col ) [protected]

314
315       Searches for widget w in this layout (not including child layouts). If
316       w is found, it sets <em>row</em> and <em>col</em> to the row and column
317       and returns TRUE; otherwise returns FALSE.
318
319       Note: if a widget spans multiple rows/columns, the top-left cell is
320       returned.
321

bool QGridLayout::hasHeightForWidth () const [virtual]

323       Returns TRUE if this layout's preferred height depends on its width;
324       otherwise returns FALSE.
325
326       Reimplemented from QLayoutItem.
327

int QGridLayout::heightForWidth ( int w ) const [virtual]

329       Returns the layout's preferred height when it is w pixels wide.
330
331       Reimplemented from QLayoutItem.
332

void QGridLayout::invalidate () [virtual]

334       Resets cached information.
335
336       Reimplemented from QLayout.
337

QSize QGridLayout::maximumSize () const [virtual]

339       Returns the maximum size needed by this grid.
340
341       Reimplemented from QLayout.
342

QSize QGridLayout::minimumSize () const [virtual]

344       Returns the minimum size needed by this grid.
345
346       Reimplemented from QLayout.
347

int QGridLayout::numCols () const

349       Returns the number of columns in this grid.
350

int QGridLayout::numRows () const

352       Returns the number of rows in this grid.
353

Corner QGridLayout::origin () const

355       Returns the corner that's used for the grid's origin, i.e. for position
356       (0, 0).
357

int QGridLayout::rowSpacing ( int row ) const

359       Returns the row spacing for row row.
360
361       See also setRowSpacing().
362

int QGridLayout::rowStretch ( int row ) const

364       Returns the stretch factor for row row.
365
366       See also setRowStretch().
367

void QGridLayout::setColSpacing ( int col, int minSize )

369       Sets the minimum width of column col to minSize pixels.
370
371       See also colSpacing() and setRowSpacing().
372

void QGridLayout::setColStretch ( int col, int stretch ) [virtual]

374       Sets the stretch factor of column col to stretch. The first column is
375       number 0.
376
377       The stretch factor is relative to the other columns in this grid.
378       Columns with a higher stretch factor take more of the available space.
379
380       The default stretch factor is 0. If the stretch factor is 0 and no
381       other column in this table can grow at all, the column may still grow.
382
383       See also colStretch(), addColSpacing(), and setRowStretch().
384
385       Examples:
386

void QGridLayout::setGeometry ( const QRect & r ) [virtual]

388       Resizes managed widgets within the rectangle r.
389
390       Reimplemented from QLayout.
391

void QGridLayout::setOrigin ( Corner c )

393       Sets the grid's origin corner, i.e. position (0, 0), to c.
394

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

396       Sets the minimum height of row row to minSize pixels.
397
398       See also rowSpacing() and setColSpacing().
399

void QGridLayout::setRowStretch ( int row, int stretch ) [virtual]

401       Sets the stretch factor of row row to stretch. The first row is number
402       0.
403
404       The stretch factor is relative to the other rows in this grid. Rows
405       with a higher stretch factor take more of the available space.
406
407       The default stretch factor is 0. If the stretch factor is 0 and no
408       other row in this table can grow at all, the row may still grow.
409
410       See also rowStretch(), setRowSpacing(), and setColStretch().
411
412       Examples:
413

QSize QGridLayout::sizeHint () const [virtual]

415       Returns the preferred size of this grid.
416
417       Reimplemented from QLayoutItem.
418
419

SEE ALSO

421       http://doc.trolltech.com/qgridlayout.html
422       http://www.trolltech.com/faq/tech.html
423
425       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
426       license file included in the distribution for a complete license
427       statement.
428

AUTHOR

430       Generated automatically from the source code.
431

BUGS

433       If you find a bug in Qt, please report it as described in
434       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
435       help you. Thank you.
436
437       The definitive Qt documentation is provided in HTML format; it is
438       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
439       web browser. This man page is provided as a convenience for those users
440       who prefer man pages, although this format is not officially supported
441       by Trolltech.
442
443       If you find errors in this manual page, please report them to qt-
444       bugs@trolltech.com.  Please include the name of the manual page
445       (qgridlayout.3qt) and the Qt version (3.3.8).
446
447
448
449Trolltech AS                    2 February 2007               QGridLayout(3qt)
Impressum