| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2010 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:LGPL$
|
|---|
| 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
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*!
|
|---|
| 43 | \class QSizePolicy
|
|---|
| 44 | \brief The QSizePolicy class is a layout attribute describing horizontal
|
|---|
| 45 | and vertical resizing policy.
|
|---|
| 46 |
|
|---|
| 47 | \ingroup geomanagement
|
|---|
| 48 |
|
|---|
| 49 | The size policy of a widget is an expression of its willingness to
|
|---|
| 50 | be resized in various ways, and affects how the widget is treated
|
|---|
| 51 | by the \l{Layout Management}{layout engine}. Each widget returns a
|
|---|
| 52 | QSizePolicy that describes the horizontal and vertical resizing
|
|---|
| 53 | policy it prefers when being laid out. You can change this for
|
|---|
| 54 | a specific widget by changing its QWidget::sizePolicy property.
|
|---|
| 55 |
|
|---|
| 56 | QSizePolicy contains two independent QSizePolicy::Policy values
|
|---|
| 57 | and two stretch factors; one describes the widgets's horizontal
|
|---|
| 58 | size policy, and the other describes its vertical size policy. It
|
|---|
| 59 | also contains a flag to indicate whether the height and width of
|
|---|
| 60 | its preferred size are related.
|
|---|
| 61 |
|
|---|
| 62 | The horizontal and vertical policies can be set in the
|
|---|
| 63 | constructor, and altered using the setHorizontalPolicy() and
|
|---|
| 64 | setVerticalPolicy() functions. The stretch factors can be set
|
|---|
| 65 | using the setHorizontalStretch() and setVerticalStretch()
|
|---|
| 66 | functions. The flag indicating whether the widget's
|
|---|
| 67 | \l{QWidget::sizeHint()}{sizeHint()} is width-dependent (such as a
|
|---|
| 68 | menu bar or a word-wrapping label) can be set using the
|
|---|
| 69 | setHeightForWidth() function.
|
|---|
| 70 |
|
|---|
| 71 | The current size policies and stretch factors be retrieved using
|
|---|
| 72 | the horizontalPolicy(), verticalPolicy(), horizontalStretch() and
|
|---|
| 73 | verticalStretch() functions. Alternatively, use the transpose()
|
|---|
| 74 | function to swap the horizontal and vertical policies and
|
|---|
| 75 | stretches. The hasHeightForWidth() function returns the current
|
|---|
| 76 | status of the flag indicating the size hint dependencies.
|
|---|
| 77 |
|
|---|
| 78 | Use the expandingDirections() function to determine whether the
|
|---|
| 79 | associated widget can make use of more space than its
|
|---|
| 80 | \l{QWidget::sizeHint()}{sizeHint()} function indicates, as well as
|
|---|
| 81 | find out in which directions it can expand.
|
|---|
| 82 |
|
|---|
| 83 | Finally, the QSizePolicy class provides operators comparing this
|
|---|
| 84 | size policy to a given policy, as well as a QVariant operator
|
|---|
| 85 | storing this QSizePolicy as a QVariant object.
|
|---|
| 86 |
|
|---|
| 87 | \sa QSize, QWidget::sizeHint(), QWidget::sizePolicy,
|
|---|
| 88 | QLayoutItem::sizeHint()
|
|---|
| 89 | */
|
|---|
| 90 |
|
|---|
| 91 | /*!
|
|---|
| 92 | \enum QSizePolicy::PolicyFlag
|
|---|
| 93 |
|
|---|
| 94 | These flags are combined together to form the various \l{Policy}
|
|---|
| 95 | values:
|
|---|
| 96 |
|
|---|
| 97 | \value GrowFlag The widget can grow beyond its size hint if necessary.
|
|---|
| 98 | \value ExpandFlag The widget should get as much space as possible.
|
|---|
| 99 | \value ShrinkFlag The widget can shrink below its size hint if necessary.
|
|---|
| 100 | \value IgnoreFlag The widget's size hint is ignored. The widget will get
|
|---|
| 101 | as much space as possible.
|
|---|
| 102 |
|
|---|
| 103 | \sa Policy
|
|---|
| 104 | */
|
|---|
| 105 |
|
|---|
| 106 | /*!
|
|---|
| 107 | \enum QSizePolicy::Policy
|
|---|
| 108 |
|
|---|
| 109 | This enum describes the various per-dimension sizing types used
|
|---|
| 110 | when constructing a QSizePolicy.
|
|---|
| 111 |
|
|---|
| 112 | \value Fixed The QWidget::sizeHint() is the only acceptable
|
|---|
| 113 | alternative, so the widget can never grow or shrink (e.g. the
|
|---|
| 114 | vertical direction of a push button).
|
|---|
| 115 |
|
|---|
| 116 | \value Minimum The sizeHint() is minimal, and sufficient. The
|
|---|
| 117 | widget can be expanded, but there is no advantage to it being
|
|---|
| 118 | larger (e.g. the horizontal direction of a push button).
|
|---|
| 119 | It cannot be smaller than the size provided by sizeHint().
|
|---|
| 120 |
|
|---|
| 121 | \value Maximum The sizeHint() is a maximum. The widget can be
|
|---|
| 122 | shrunk any amount without detriment if other widgets need the
|
|---|
| 123 | space (e.g. a separator line).
|
|---|
| 124 | It cannot be larger than the size provided by sizeHint().
|
|---|
| 125 |
|
|---|
| 126 | \value Preferred The sizeHint() is best, but the widget can be
|
|---|
| 127 | shrunk and still be useful. The widget can be expanded, but there
|
|---|
| 128 | is no advantage to it being larger than sizeHint() (the default
|
|---|
| 129 | QWidget policy).
|
|---|
| 130 |
|
|---|
| 131 | \value Expanding The sizeHint() is a sensible size, but the
|
|---|
| 132 | widget can be shrunk and still be useful. The widget can make use
|
|---|
| 133 | of extra space, so it should get as much space as possible (e.g.
|
|---|
|
|---|