Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy. More...
#include <QSizePolicy>
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
The size policy of a widget is an expression of its willingness to be resized in various ways.
Widgets that reimplement QWidget::sizePolicy() return a QSizePolicy that describes the horizontal and vertical resizing policy they prefer when being laid out.
QSizePolicy contains two independent QSizePolicy::Policy values and two stretch factors; one describes the widgets's horizontal size policy, and the other describes its vertical size policy. It also contains a flag to indicate whether the height and width of its preferred size are related.
The horizontal and vertical policies are set in the usual constructor and can be queried using horizontalPolicy() and verticalPolicy().
The hasHeightForWidth() flag indicates whether the widget's sizeHint() is width-dependent (such as a menu bar or a word-wrapping label).
See also QSize, QWidget::sizeHint(), QWidget::sizePolicy(), and QLayoutItem::sizeHint().
The per-dimension sizing types used when constructing a QSizePolicy are:
Constant | Value | Description |
---|---|---|
QSizePolicy::Fixed | 0 | The QWidget::sizeHint() is the only acceptable alternative, so the widget can never grow or shrink (e.g. the vertical direction of a push button). |
QSizePolicy::Minimum | GrowFlag | The sizeHint() is minimal, and sufficient. The widget can be expanded, but there is no advantage to it being larger (e.g. the horizontal direction of a push button). It cannot be smaller than the size provided by sizeHint(). |
QSizePolicy::Maximum | ShrinkFlag | The sizeHint() is a maximum. The widget can be shrunk any amount without detriment if other widgets need the space (e.g. a separator line). It cannot be larger than the size provided by sizeHint(). |
QSizePolicy::Preferred | GrowFlag | ShrinkFlag | The sizeHint() is best, but the widget can be shrunk and still be useful. The widget can be expanded, but there is no advantage to it being larger than sizeHint() (the default QWidget policy). |
QSizePolicy::Expanding | GrowFlag | ShrinkFlag | ExpandFlag | The sizeHint() is a sensible size, but the widget can be shrunk and still be useful. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a slider). |
QSizePolicy::MinimumExpanding | GrowFlag | ExpandFlag | The sizeHint() is minimal, and sufficient. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a slider). |
QSizePolicy::Ignored | ShrinkFlag | GrowFlag | IgnoreFlag | The sizeHint() is ignored. The widget will get as much space as possible. |
See also PolicyFlag.
These flags are combined together to form the various Policy values:
Constant | Value | Description |
---|---|---|
QSizePolicy::GrowFlag | 1 | The widget can grow beyond its size hint if necessary. |
QSizePolicy::ExpandFlag | 2 | The widget should get as much space as possible. |
QSizePolicy::ShrinkFlag | 4 | The widget can shrink below its size hint if necessary. |
QSizePolicy::IgnoreFlag | 8 | The widget's size hint is ignored. The widget will get as much space as possible. |
See also Policy.
Constructs a QSizePolicy with Fixed as its horizontal and vertical policies.
See also setHorizontalPolicy(), setVerticalPolicy(), setHorizontalStretch(), setVerticalStretch(), and setHeightForWidth().
It constructs a QSizePolicy with independent horizontal and vertical policies, horizontal and vertical respectively. These policies affect how the widget is treated by the layout engine.
Use setHeightForWidth() if the preferred height of the widget is dependent on the width of the widget (for example, a QLabel with line wrapping).
See also horizontalPolicy(), verticalPolicy(), and setHeightForWidth().
Returns whether this widget can make use of more space than sizeHint(). A value of Qt::Horizontal or Qt::Vertical means that the widget wants to grow horizontally or vertically (i.e., the horizontal or vertical policy is Expanding or MinimumExpanding), whereas Qt::Horizontal | Qt::Vertical means that it wants to grow in both dimensions.
See also horizontalPolicy() and verticalPolicy().
Returns true if the widget's preferred height depends on its width; otherwise returns false.
See also setHeightForWidth().
Returns the horizontal component of the size policy.
See also setHorizontalPolicy(), verticalPolicy(), and horizontalStretch().
Returns the horizontal stretch factor of the size policy.
See also setHorizontalStretch() and verticalStretch().
Sets the hasHeightForWidth() flag to hfw.
See also hasHeightForWidth().
Sets the horizontal component of the size policy to policy.
See also horizontalPolicy() and setVerticalPolicy().
Sets the horizontal stretch factor of the size policy to stretch.
See also horizontalStretch() and setVerticalStretch().
Sets the vertical component of the size policy to policy.
See also verticalPolicy() and setHorizontalPolicy().
Sets the vertical stretch factor of the size policy to stretch.
See also verticalStretch() and setHorizontalStretch().
Swaps the horizontal and vertical policies and stretches.
Returns the vertical component of the size policy.
See also setVerticalPolicy(), horizontalPolicy(), and verticalStretch().
Returns the vertical stretch factor of the size policy.
See also setVerticalStretch() and horizontalStretch().
Returns a QVariant storing this QSizePolicy.
Returns true if this policy is different from other; otherwise returns false.
See also operator==().
Returns true if this policy is equal to other; otherwise returns false.
See also operator!=().
Copyright © 2005 Trolltech | Trademarks | Qt 4.1.0 |