source: trunk/src/gui/kernel/qsizepolicy.qdoc

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 15.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29 \class QSizePolicy
30 \brief The QSizePolicy class is a layout attribute describing horizontal
31 and vertical resizing policy.
32
33 \ingroup geomanagement
34
35 The size policy of a widget is an expression of its willingness to
36 be resized in various ways, and affects how the widget is treated
37 by the \l{Layout Management}{layout engine}. Each widget returns a
38 QSizePolicy that describes the horizontal and vertical resizing
39 policy it prefers when being laid out. You can change this for
40 a specific widget by changing its QWidget::sizePolicy property.
41
42 QSizePolicy contains two independent QSizePolicy::Policy values
43 and two stretch factors; one describes the widgets's horizontal
44 size policy, and the other describes its vertical size policy. It
45 also contains a flag to indicate whether the height and width of
46 its preferred size are related.
47
48 The horizontal and vertical policies can be set in the
49 constructor, and altered using the setHorizontalPolicy() and
50 setVerticalPolicy() functions. The stretch factors can be set
51 using the setHorizontalStretch() and setVerticalStretch()
52 functions. The flag indicating whether the widget's
53 \l{QWidget::sizeHint()}{sizeHint()} is width-dependent (such as a
54 menu bar or a word-wrapping label) can be set using the
55 setHeightForWidth() function.
56
57 The current size policies and stretch factors be retrieved using
58 the horizontalPolicy(), verticalPolicy(), horizontalStretch() and
59 verticalStretch() functions. Alternatively, use the transpose()
60 function to swap the horizontal and vertical policies and
61 stretches. The hasHeightForWidth() function returns the current
62 status of the flag indicating the size hint dependencies.
63
64 Use the expandingDirections() function to determine whether the
65 associated widget can make use of more space than its
66 \l{QWidget::sizeHint()}{sizeHint()} function indicates, as well as
67 find out in which directions it can expand.
68
69 Finally, the QSizePolicy class provides operators comparing this
70 size policy to a given policy, as well as a QVariant operator
71 storing this QSizePolicy as a QVariant object.
72
73 \sa QSize, QWidget::sizeHint(), QWidget::sizePolicy,
74 QLayoutItem::sizeHint()
75*/
76
77/*!
78 \enum QSizePolicy::PolicyFlag
79
80 These flags are combined together to form the various \l{Policy}
81 values:
82
83 \value GrowFlag The widget can grow beyond its size hint if necessary.
84 \value ExpandFlag The widget should get as much space as possible.
85 \value ShrinkFlag The widget can shrink below its size hint if necessary.
86 \value IgnoreFlag The widget's size hint is ignored. The widget will get
87 as much space as possible.
88
89 \sa Policy
90*/
91
92/*!
93 \enum QSizePolicy::Policy
94
95 This enum describes the various per-dimension sizing types used
96 when constructing a QSizePolicy.
97
98 \value Fixed The QWidget::sizeHint() is the only acceptable
99 alternative, so the widget can never grow or shrink (e.g. the
100 vertical direction of a push button).
101
102 \value Minimum The sizeHint() is minimal, and sufficient. The
103 widget can be expanded, but there is no advantage to it being
104 larger (e.g. the horizontal direction of a push button).
105 It cannot be smaller than the size provided by sizeHint().
106
107 \value Maximum The sizeHint() is a maximum. The widget can be
108 shrunk any amount without detriment if other widgets need the
109 space (e.g. a separator line).
110 It cannot be larger than the size provided by sizeHint().
111
112 \value Preferred The sizeHint() is best, but the widget can be
113 shrunk and still be useful. The widget can be expanded, but there
114 is no advantage to it being larger than sizeHint() (the default
115 QWidget policy).
116
117 \value Expanding The sizeHint() is a sensible size, but the
118 widget can be shrunk and still be useful. The widget can make use
119 of extra space, so it should get as much space as possible (e.g.
120 the horizontal direction of a horizontal slider).
121
122 \value MinimumExpanding The sizeHint() is minimal, and sufficient.
123 The widget can make use of extra space, so it should get as much
124 space as possible (e.g. the horizontal direction of a horizontal
125 slider).
126
127 \value Ignored The sizeHint() is ignored. The widget will get as
128 much space as possible.
129
130 \sa PolicyFlag, setHorizontalPolicy(), setVerticalPolicy()
131*/
132
133/*!
134 \fn QSizePolicy::QSizePolicy()
135
136 Constructs a QSizePolicy object with \l Fixed as its horizontal
137 and vertical policies.
138
139 The policies can be altered using the setHorizontalPolicy() and
140 setVerticalPolicy() functions. Use the setHeightForWidth()
141 function if the preferred height of the widget is dependent on the
142 width of the widget (for example, a QLabel with line wrapping).
143
144 \sa setHorizontalStretch(), setVerticalStretch()
145*/
146
147/*!
148 \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical)
149
150 Constructs a QSizePolicy object with the given \a horizontal and
151 \a vertical policies, and DefaultType as the control type.
152
153 Use setHeightForWidth() if the preferred height of the widget is
154 dependent on the width of the widget (for example, a QLabel with
155 line wrapping).
156
157 \sa setHorizontalStretch(), setVerticalStretch()
158*/
159
160/*!
161 \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, ControlType type)
162 \since 4.3
163
164 Constructs a QSizePolicy object with the given \a horizontal and
165 \a vertical policies, and the specified control \a type.
166
167 Use setHeightForWidth() if the preferred height of the widget is
168 dependent on the width of the widget (for example, a QLabel with
169 line wrapping).
170
171 \sa setHorizontalStretch(), setVerticalStretch(), controlType()
172*/
173
174/*!
175 \fn QSizePolicy::Policy QSizePolicy::horizontalPolicy() const
176
177 Returns the horizontal component of the size policy.
178
179 \sa setHorizontalPolicy(), verticalPolicy(), horizontalStretch()
180*/
181
182/*!
183 \fn QSizePolicy::Policy QSizePolicy::verticalPolicy() const
184
185 Returns the vertical component of the size policy.
186
187 \sa setVerticalPolicy(), horizontalPolicy(), verticalStretch()
188*/
189
190/*!
191 \fn void QSizePolicy::setHorizontalPolicy(Policy policy)
192
193 Sets the horizontal component to the given \a policy.
194
195 \sa horizontalPolicy(), setVerticalPolicy(), setHorizontalStretch()
196*/
197
198/*!
199 \fn void QSizePolicy::setVerticalPolicy(Policy policy)
200
201 Sets the vertical component to the given \a policy.
202
203 \sa verticalPolicy(), setHorizontalPolicy(), setVerticalStretch()
204*/
205
206/*!
207 \fn Qt::Orientations QSizePolicy::expandingDirections() const
208
209 Returns whether a widget can make use of more space than the
210 QWidget::sizeHint() function indicates.
211
212 A value of Qt::Horizontal or Qt::Vertical means that the widget
213 can grow horizontally or vertically (i.e., the horizontal or
214 vertical policy is \l Expanding or \l MinimumExpanding), whereas
215 Qt::Horizontal | Qt::Vertical means that it can grow in both
216 dimensions.
217
218 \sa horizontalPolicy(), verticalPolicy()
219*/
220
221/*!
222 \fn ControlType QSizePolicy::controlType() const
223 \since 4.3
224
225 Returns the control type associated with the widget for which
226 this size policy applies.
227*/
228
229/*!
230 \fn void QSizePolicy::setControlType(ControlType type)
231 \since 4.3
232
233 Sets the control type associated with the widget for which this
234 size policy applies to \a type.
235
236 The control type specifies the type of the widget for which this
237 size policy applies. It is used by some styles, notably
238 QMacStyle, to insert proper spacing between widgets. For example,
239 the Mac OS X Aqua guidelines specify that push buttons should be
240 separated by 12 pixels, whereas vertically stacked radio buttons
241 only require 6 pixels.
242
243 \sa QStyle::layoutSpacing()
244*/
245
246/*!
247 \fn void QSizePolicy::setHeightForWidth(bool dependent)
248
249 Sets the flag determining whether the widget's preferred height
250 depends on its width, to \a dependent.
251
252 \sa hasHeightForWidth()
253*/
254
255/*!
256 \fn bool QSizePolicy::hasHeightForWidth() const
257
258 Returns true if the widget's preferred height depends on its
259 width; otherwise returns false.
260
261 \sa setHeightForWidth()
262*/
263
264/*!
265 \fn bool QSizePolicy::operator==(const QSizePolicy &other) const
266
267 Returns true if this policy is equal to \a other; otherwise
268 returns false.
269
270 \sa operator!=()
271*/
272
273/*!
274 \fn bool QSizePolicy::operator!=(const QSizePolicy &other) const
275
276 Returns true if this policy is different from \a other; otherwise
277 returns false.
278
279 \sa operator==()
280*/
281
282/*!
283 \fn int QSizePolicy::horizontalStretch() const
284
285 Returns the horizontal stretch factor of the size policy.
286
287 \sa setHorizontalStretch(), verticalStretch(), horizontalPolicy()
288*/
289
290/*!
291 \fn int QSizePolicy::verticalStretch() const
292
293 Returns the vertical stretch factor of the size policy.
294
295 \sa setVerticalStretch(), horizontalStretch(), verticalPolicy()
296*/
297
298/*!
299 \fn void QSizePolicy::setHorizontalStretch(uchar stretchFactor)
300
301 Sets the horizontal stretch factor of the size policy to the given \a
302 stretchFactor.
303
304 \sa horizontalStretch(), setVerticalStretch(), setHorizontalPolicy()
305*/
306
307/*!
308 \fn void QSizePolicy::setVerticalStretch(uchar stretchFactor)
309
310 Sets the vertical stretch factor of the size policy to the given
311 \a stretchFactor.
312
313 \sa verticalStretch(), setHorizontalStretch(), setVerticalPolicy()
314*/
315
316/*!
317 \fn void QSizePolicy::transpose()
318
319 Swaps the horizontal and vertical policies and stretches.
320*/
321
322/*!
323 \enum QSizePolicy::ControlType
324 \since 4.3
325
326 This enum specifies the different types of widgets in terms of
327 layout interaction:
328
329 \value DefaultType The default type, when none is specified.
330 \value ButtonBox A QDialogButtonBox instance.
331 \value CheckBox A QCheckBox instance.
332 \value ComboBox A QComboBox instance.
333 \value Frame A QFrame instance.
334 \value GroupBox A QGroupBox instance.
335 \value Label A QLabel instance.
336 \value Line A QFrame instance with QFrame::HLine or QFrame::VLine.
337 \value LineEdit A QLineEdit instance.
338 \value PushButton A QPushButton instance.
339 \value RadioButton A QRadioButton instance.
340 \value Slider A QAbstractSlider instance.
341 \value SpinBox A QAbstractSpinBox instance.
342 \value TabWidget A QTabWidget instance.
343 \value ToolButton A QToolButton instance.
344
345 \sa setControlType(), controlType()
346*/
347
348#ifdef QT3_SUPPORT
349/*!
350 \typedef QSizePolicy::SizeType
351 \compat
352
353 Use the QSizePolicy::Policy enum instead.
354*/
355
356/*!
357 \enum QSizePolicy::ExpandData
358 \compat
359
360 Use the Qt::Orientations enum instead.
361
362 \value NoDirection Use 0 instead.
363 \value Horizontally Use Qt::Horizontal instead.
364 \value Vertically Use Qt::Vertical instead.
365 \value BothDirections Use Qt::Horizontal | Qt::Vertical instead.
366*/
367
368/*!
369 \fn bool QSizePolicy::mayShrinkHorizontally() const
370
371 Use the horizontalPolicy() function combined with the
372 QSizePolicy::PolicyFlag enum instead.
373
374 \oldcode
375 bool policy = mayShrinkHorizontally();
376 \newcode
377 bool policy = horizontalPolicy() & QSizePolicy::ShrinkFlag;
378 \endcode
379*/
380
381/*!
382 \fn bool QSizePolicy::mayShrinkVertically() const
383
384 Use the verticalPolicy() function combined with the
385 QSizePolicy::PolicyFlag enum instead.
386
387 \oldcode
388 bool policy = mayShrinkVertically();
389 \newcode
390 bool policy = verticalPolicy() & QSizePolicy::ShrinkFlag;
391 \endcode
392*/
393
394/*!
395 \fn bool QSizePolicy::mayGrowHorizontally() const
396
397 Use the horizontalPolicy() function combined with the
398 QSizePolicy::PolicyFlag enum instead.
399
400 \oldcode
401 bool policy = mayGrowHorizontally();
402 \newcode
403 bool policy = horizontalPolicy() & QSizePolicy::GrowFlag;
404 \endcode
405*/
406
407/*!
408 \fn bool QSizePolicy::mayGrowVertically() const
409
410 Use the verticalPolicy() function combined with the
411 QSizePolicy::PolicyFlag enum instead.
412
413 \oldcode
414 bool policy = mayGrowVertically();
415 \newcode
416 bool policy = verticalPolicy() & QSizePolicy::GrowFlag;
417 \endcode
418*/
419
420/*!
421 \fn Qt::QSizePolicy::Orientations QSizePolicy::expanding() const
422
423 Use expandingDirections() instead.
424*/
425
426/*!
427 \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, bool dependent)
428
429 Use the QSizePolicy() constructor and the setHeightForWidth()
430 function instead.
431
432 \oldcode
433 QSizePolicy *policy = new QSizePolicy(horizontal, vertical, dependent);
434 \newcode
435 QSizePolicy *policy = new QSizePolicy(horizontal, vertical);
436 policy->setHeightForWidth(dependent);
437 \endcode
438*/
439
440/*!
441 \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, uchar horizontalStretch,
442 uchar verticalStretch, bool dependent)
443
444 Use the QSizePolicy() constructor and call the
445 setHorizontalStretch(), setVerticalStretch(), and
446 setHeightForWidth() functions instead.
447
448 \oldcode
449 QSizePolicy *policy = new QSizePolicy(horizontal, vertical,
450 horizontalStretch, verticalStretch,
451 dependent);
452 \newcode
453 QSizePolicy *policy = new QSizePolicy(horizontal, vertical);
454 policy->setHorizontalStretch(horizontalStretch);
455 policy->setVerticalStretch(verticalStretch);
456 policy->setHeightForWidth(dependent);
457 \endcode
458*/
459
460/*!
461 \fn QSizePolicy::Policy QSizePolicy::horData() const
462
463 Use horizontalPolicy() instead.
464*/
465
466/*!
467 \fn QSizePolicy::Policy QSizePolicy::verData() const
468
469 Use verticalPolicy() instead.
470*/
471
472/*!
473 \fn void QSizePolicy::setHorData(Policy policy)
474
475 Use setHorizontalPolicy() instead.
476*/
477
478/*!
479 \fn void QSizePolicy::setVerData(Policy policy)
480
481 Use setVerticalPolicy() instead.
482*/
483
484/*!
485 \fn uint QSizePolicy::horStretch() const
486
487 Use horizontalStretch() instead.
488*/
489
490/*!
491 \fn uint QSizePolicy::verStretch() const
492
493 Use verticalStretch() instead.
494*/
495
496/*!
497 \fn void QSizePolicy::setHorStretch(uchar stretch)
498
499 Use setHorizontalStretch() instead.
500*/
501
502/*!
503 \fn void QSizePolicy::setVerStretch(uchar stretch)
504
505 Use setVerticalStretch() instead.
506*/
507#endif
Note: See TracBrowser for help on using the repository browser.