1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
'\" t
.TH QLayout 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QLayout \- The base class of geometry managers
.SH SYNOPSIS
\fC#include <qlayout.h>\fR
.PP
Inherits QObject and QLayoutItem.
.PP
Inherited by QGridLayout and QBoxLayout.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "enum \fBResizeMode\fR { FreeResize, Minimum, Fixed, Auto }"
.br
.ti -1c
.BI "\fBQLayout\fR ( QWidget * parent, int margin = 0, int spacing = -1, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQLayout\fR ( QLayout * parentLayout, int spacing = -1, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQLayout\fR ( int spacing = -1, const char * name = 0 )"
.br
.ti -1c
.BI "int \fBmargin\fR () const"
.br
.ti -1c
.BI "int \fBspacing\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetMargin\fR ( int )"
.br
.ti -1c
.BI "virtual void \fBsetSpacing\fR ( int )"
.br
.ti -1c
.BI "void \fBsetResizeMode\fR ( ResizeMode )"
.br
.ti -1c
.BI "ResizeMode \fBresizeMode\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetMenuBar\fR ( QMenuBar * w )"
.br
.ti -1c
.BI "QMenuBar * \fBmenuBar\fR () const"
.br
.ti -1c
.BI "QWidget * \fBmainWidget\fR ()"
.br
.ti -1c
.BI "bool \fBisTopLevel\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetAutoAdd\fR ( bool b )"
.br
.ti -1c
.BI "bool \fBautoAdd\fR () const"
.br
.ti -1c
.BI "virtual void \fBinvalidate\fR ()"
.br
.ti -1c
.BI "bool \fBactivate\fR ()"
.br
.ti -1c
.BI "void \fBadd\fR ( QWidget * w )"
.br
.ti -1c
.BI "virtual void \fBaddItem\fR ( QLayoutItem * item ) = 0"
.br
.ti -1c
.BI "void \fBremove\fR ( QWidget * widget )"
.br
.ti -1c
.BI "void \fBremoveItem\fR ( QLayoutItem * item )"
.br
.ti -1c
.BI "virtual QSizePolicy::ExpandData \fBexpanding\fR () const"
.br
.ti -1c
.BI "virtual QSize \fBminimumSize\fR () const"
.br
.ti -1c
.BI "virtual QSize \fBmaximumSize\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetGeometry\fR ( const QRect & r ) = 0"
.br
.ti -1c
.BI "virtual QLayoutIterator \fBiterator\fR () = 0"
.br
.ti -1c
.BI "virtual bool \fBisEmpty\fR () const"
.br
.ti -1c
.BI "bool \fBsupportsMargin\fR () const"
.br
.ti -1c
.BI "void \fBsetEnabled\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBisEnabled\fR () const"
.br
.in -1c
.SS "Properties"
.in +1c
.ti -1c
.BI "int \fBmargin\fR - the width of the outside border of the layout"
.br
.ti -1c
.BI "ResizeMode \fBresizeMode\fR - the resize mode of the layout"
.br
.ti -1c
.BI "int \fBspacing\fR - the spacing between widgets inside the layout"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "void \fBaddChildLayout\fR ( QLayout * l )"
.br
.ti -1c
.BI "void \fBdeleteAllItems\fR ()"
.br
.ti -1c
.BI "void \fBsetSupportsMargin\fR ( bool b )"
.br
.ti -1c
.BI "QRect \fBalignmentRect\fR ( const QRect & r ) const"
.br
.in -1c
.SH DESCRIPTION
The QLayout class is the base class of geometry managers.
.PP
This is an abstract base class inherited by the concrete classes, QBoxLayout and QGridLayout.
.PP
For users of QLayout subclasses or of QMainWindow there is seldom any need to use the basic functions provided by QLayout, such as setResizeMode() or setMenuBar(). See the layout overview page for more information.
.PP
To make your own layout manager, subclass QGLayoutIterator and implement the functions addItem(), sizeHint(), setGeometry(), and iterator(). You should also implement minimumSize() to ensure your layout isn't resized to zero size if there is too little space. To support children whose heights depend on their widths, implement hasHeightForWidth() and heightForWidth(). See the custom layout page for an in-depth description.
.PP
Geometry management stops when the layout manager is deleted.
.PP
See also Widget Appearance and Style and Layout Management.
.SS "Member Type Documentation"
.SH "QLayout::ResizeMode"
The possible values are:
.TP
\fCQLayout::Auto\fR - If the main widget is a top-level widget with no height-for-width (hasHeightForWidth()), this is the same as \fCMinimium\fR; otherwise, this is the same as FreeResize.
.TP
\fCQLayout::Fixed\fR - The main widget's size is set to sizeHint(); it cannot be resized at all.
.TP
\fCQLayout::Minimum\fR - The main widget's minimum size is set to minimumSize(); it cannot be smaller.
.TP
\fCQLayout::FreeResize\fR - The widget is not constrained.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QLayout::QLayout ( QWidget * parent, int margin = 0, int spacing = -1, const char * name = 0 )"
Constructs a new top-level QLayout called \fIname\fR, with main widget \fIparent\fR. \fIparent\fR may not be 0.
.PP
The \fImargin\fR is the number of pixels between the edge of the widget and the managed children. The \fIspacing\fR sets the value of spacing(), which gives the spacing between the managed widgets. If \fIspacing\fR is -1 (the default), spacing is set to the value of \fImargin\fR.
.PP
There can be only one top-level layout for a widget. It is returned by QWidget::layout()
.SH "QLayout::QLayout ( QLayout * parentLayout, int spacing = -1, const char * name = 0 )"
Constructs a new child QLayout called \fIname\fR, and places it inside \fIparentLayout\fR by using the default placement defined by addItem().
.PP
If \fIspacing\fR is -1, this QLayout inherits \fIparentLayout\fR's spacing(), otherwise the value of \fIspacing\fR is used.
.SH "QLayout::QLayout ( int spacing = -1, const char * name = 0 )"
Constructs a new child QLayout called \fIname\fR. If \fIspacing\fR is -1, this QLayout inherits its parent's spacing(); otherwise the value of \fIspacing\fR is used.
.PP
This layout has to be inserted into another layout before geometry management will work.
.SH "bool QLayout::activate ()"
Redoes the layout for mainWidget(). You should generally not need to call this because it is automatically called at the most appropriate times.
.PP
However, if you set up a QLayout for a visible widget without resizing that widget, you will need to call this function in order to lay it out.
.PP
See also QWidget::updateGeometry().
.PP
Examples:
.)l layout/layout.cpp, popup/popup.cpp, scrollview/scrollview.cpp, and sql/overview/form1/main.cpp.
.SH "void QLayout::add ( QWidget * w )"
Adds widget \fIw\fR to this layout in a manner specific to the layout. This function uses addItem().
.PP
Examples:
.)l customlayout/border.cpp and customlayout/main.cpp.
.SH "void QLayout::addChildLayout ( QLayout * l )\fC [protected]\fR"
This function is called from addLayout() functions in subclasses to add layout \fIl\fR as a sub-layout.
.SH "void QLayout::addItem ( QLayoutItem * item )\fC [pure virtual]\fR"
Implemented in subclasses to add an \fIitem\fR. How it is added is specific to each subclass.
.PP
The ownership of \fIitem\fR is transferred to the layout, and it's the layout's responsibility to delete it.
.PP
Examples:
.)l customlayout/border.cpp, customlayout/card.cpp, and customlayout/flow.cpp.
.PP
Reimplemented in QGridLayout and QBoxLayout.
.SH "QRect QLayout::alignmentRect ( const QRect & r ) const\fC [protected]\fR"
Returns the rectangle that should be covered when the geometry of this layout is set to \fIr\fR, provided that this layout supports setAlignment().
.PP
The result is derived from sizeHint() and expanding(). It is never larger than \fIr\fR.
.SH "bool QLayout::autoAdd () const"
Returns TRUE if this layout automatically grabs all new mainWidget()'s new children and adds them as defined by addItem(); otherwise returns FALSE. This has effect only for top-level layouts, i.e. layouts that are direct children of their mainWidget().
.PP
autoAdd() is disabled by default.
.PP
Note that a top-level layout is not necessarily associated with the top-level widget.
.PP
See also setAutoAdd().
.SH "void QLayout::deleteAllItems ()\fC [protected]\fR"
Removes and deletes all items in this layout.
.SH "QSizePolicy::ExpandData QLayout::expanding () const\fC [virtual]\fR"
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.
.PP
The default implementation returns \fCBothDirections\fR.
.PP
Examples:
.)l customlayout/border.cpp and customlayout/flow.cpp.
.PP
Reimplemented from QLayoutItem.
.PP
Reimplemented in QGridLayout and QBoxLayout.
.SH "void QLayout::invalidate ()\fC [virtual]\fR"
Invalidates cached information. Reimplementations must call this.
.PP
Reimplemented from QLayoutItem.
.PP
Reimplemented in QGridLayout and QBoxLayout.
.SH "bool QLayout::isEmpty () const\fC [virtual]\fR"
Returns TRUE if this layout is empty. The default implementation returns FALSE.
.PP
Reimplemented from QLayoutItem.
.SH "bool QLayout::isEnabled () const"
Returns TRUE if the layout is enabled; otherwise returns FALSE.
.PP
See also setEnabled().
.SH "bool QLayout::isTopLevel () const"
Returns TRUE if this layout is a top-level layout, i.e. not a child of another layout; otherwise returns FALSE.
.SH "QLayoutIterator QLayout::iterator ()\fC [pure virtual]\fR"
Implemented in subclasses to return an iterator that iterates over this layout's children.
.PP
A typical implementation will be:
.PP
.nf
.br
QLayoutIterator MyLayout::iterator()
.br
{
.br
QGLayoutIterator *i = new MyLayoutIterator( internal_data );
.br
return QLayoutIterator( i );
.br
}
.br
.fi
where MyLayoutIterator is a subclass of QGLayoutIterator.
.PP
Examples:
.)l customlayout/border.cpp, customlayout/card.cpp, and customlayout/flow.cpp.
.PP
Reimplemented from QLayoutItem.
.SH "QWidget * QLayout::mainWidget ()"
Returns the main widget (parent widget) of this layout, or 0 if this layout is a sub-layout that is not yet inserted.
.SH "int QLayout::margin () const"
Returns the width of the outside border of the layout. See the "margin" property for details.
.SH "QSize QLayout::maximumSize () const\fC [virtual]\fR"
Returns the maximum size of this layout. This is the largest size that the layout can have while still respecting the specifications. Does not include what's needed by margin() or menuBar().
.PP
The default implementation allows unlimited resizing.
.PP
Reimplemented from QLayoutItem.
.PP
Reimplemented in QGridLayout and QBoxLayout.
.SH "QMenuBar * QLayout::menuBar () const"
Returns the menu bar set for this layout, or 0 if no menu bar is set.
.SH "QSize QLayout::minimumSize () const\fC [virtual]\fR"
Returns the minimum size of this layout. This is the smallest size that the layout can have while still respecting the specifications. Does not include what's needed by margin() or menuBar().
.PP
The default implementation allows unlimited resizing.
.PP
Examples:
.)l customlayout/border.cpp, customlayout/card.cpp, and customlayout/flow.cpp.
.PP
Reimplemented from QLayoutItem.
.PP
Reimplemented in QGridLayout and QBoxLayout.
.SH "void QLayout::remove ( QWidget * widget )"
Removes the widget \fIwidget\fR from the layout. After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout.
.PP
See also removeItem(), QWidget::geometry, and add().
.SH "void QLayout::removeItem ( QLayoutItem * item )"
Removes the layout item \fIitem\fR from the layout. It is the caller's responsibility to delete the item.
.PP
Notice that \fIitem\fR can be a layout (since QLayout inherits QLayoutItem).
.PP
See also remove() and addItem().
.SH "ResizeMode QLayout::resizeMode () const"
Returns the resize mode of the layout. See the "resizeMode" property for details.
.SH "void QLayout::setAutoAdd ( bool b )\fC [virtual]\fR"
If \fIb\fR is TRUE, auto-add is enabled; otherwise auto-add is disabled.
.PP
\fBWarning:\fR If auto-add is enabled, you cannot set stretch factors on the child widgets until the widgets are actually inserted in the layout (after control returned to the event loop). We therefore recommend that you avoid the auto-add feature in new programs.
.PP
See also autoAdd().
.PP
Examples:
.)l hierarchy/objects.cpp and i18n/main.cpp.
.SH "void QLayout::setEnabled ( bool enable )"
Enables this layout if \fIenable\fR is TRUE, otherwise disables it.
.PP
An enabled layout adjusts dynamically to changes; a disabled layout acts as if it did not exist.
.PP
By default all layouts are enabled.
.PP
See also isEnabled().
.SH "void QLayout::setGeometry ( const QRect & r )\fC [pure virtual]\fR"
This function is reimplemented in subclasses to perform layout.
.PP
The default implementation maintains the geometry() information given by rect \fIr\fR. Reimplementors must call this function.
.PP
Examples:
.)l customlayout/border.cpp, customlayout/card.cpp, and customlayout/flow.cpp.
.PP
Reimplemented from QLayoutItem.
.PP
Reimplemented in QGridLayout and QBoxLayout.
.SH "void QLayout::setMargin ( int )\fC [virtual]\fR"
Sets the width of the outside border of the layout. See the "margin" property for details.
.SH "void QLayout::setMenuBar ( QMenuBar * w )\fC [virtual]\fR"
Makes the geometry manager take account of the menu bar \fIw\fR. All child widgets are placed below the bottom edge of the menu bar.
.PP
A menu bar does its own geometry management: never do addWidget() on a QMenuBar.
.PP
Examples:
.)l layout/layout.cpp and scrollview/scrollview.cpp.
.SH "void QLayout::setResizeMode ( ResizeMode )"
Sets the resize mode of the layout. See the "resizeMode" property for details.
.SH "void QLayout::setSpacing ( int )\fC [virtual]\fR"
Sets the spacing between widgets inside the layout. See the "spacing" property for details.
.SH "void QLayout::setSupportsMargin ( bool b )\fC [protected]\fR"
Sets the value returned by supportsMargin(). If \fIb\fR is TRUE, margin() handling is implemented by the subclass. If \fIb\fR is FALSE (the default), QLayout will add margin() around top-level layouts.
.PP
If \fIb\fR is TRUE, margin handling needs to be implemented in setGeometry(), maximumSize(), minimumSize(), sizeHint() and heightForWidth().
.PP
See also supportsMargin().
.SH "int QLayout::spacing () const"
Returns the spacing between widgets inside the layout. See the "spacing" property for details.
.SH "bool QLayout::supportsMargin () const"
Returns TRUE if this layout supports QLayout::margin on non-top-level layouts; otherwise returns FALSE.
.PP
See also margin.
.SS "Property Documentation"
.SH "int margin"
This property holds the width of the outside border of the layout.
.PP
For some layout classes this property has an effect only on top-level layouts; QBoxLayout and QGridLayout support margins for child layouts. The default value is 0.
.PP
See also spacing.
.PP
Set this property's value with setMargin() and get this property's value with margin().
.SH "ResizeMode resizeMode"
This property holds the resize mode of the layout.
.PP
The default mode is Auto.
.PP
See also QLayout::ResizeMode.
.PP
Set this property's value with setResizeMode() and get this property's value with resizeMode().
.SH "int spacing"
This property holds the spacing between widgets inside the layout.
.PP
The default value is -1, which signifies that the layout's spacing should not override the widget's spacing.
.PP
See also margin.
.PP
Set this property's value with setSpacing() and get this property's value with spacing().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/qlayout.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qlayout.3qt) and the Qt
version (3.3.8).
|