Skip to content

PythonQt.QtGui.QSizePolicy

QSizePolicy

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

The size policy of a widget is an expression of its willingness to be resized in various ways, and affects how the widget is treated by the layout engine. Each widget returns a QSizePolicy that describes the horizontal and vertical resizing policy it prefers when being laid out. You can change this for a specific widget by changing its QWidget::sizePolicy property.

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 can be set in the constructor, and altered using the setHorizontalPolicy() and setVerticalPolicy() functions. The stretch factors can be set using the setHorizontalStretch() and setVerticalStretch() functions. The flag indicating whether the widget's sizeHint() is width-dependent (such as a menu bar or a word-wrapping label) can be set using the setHeightForWidth() function.

The current size policies and stretch factors be retrieved using the horizontalPolicy(), verticalPolicy(), horizontalStretch() and verticalStretch() functions. Alternatively, use the transpose() function to swap the horizontal and vertical policies and stretches. The hasHeightForWidth() function returns the current status of the flag indicating the size hint dependencies.

Use the expandingDirections() function to determine whether the associated widget can make use of more space than its sizeHint() function indicates, as well as find out in which directions it can expand.

Finally, the QSizePolicy class provides operators comparing this size policy to a given policy, as well as a QVariant operator storing this QSizePolicy as a QVariant object.

Source: https://doc.qt.io/archives/qt-5.15/qsizepolicy.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
ButtonBox attribute Any
CheckBox attribute Any
ComboBox attribute Any
ControlType attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
ControlTypes attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
DefaultType attribute Any
ExpandFlag attribute Any
Expanding attribute Any
Fixed attribute Any (shared captured text)
Frame attribute Any
GroupBox attribute Any
GrowFlag attribute Any
IgnoreFlag attribute Any
Ignored attribute Any
Label attribute Any
Line attribute Any (shared captured text)
LineEdit attribute Any
Maximum attribute Any
Minimum attribute Any
MinimumExpanding attribute Any
Policy attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
PolicyFlag attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
Preferred attribute Any
PushButton attribute Any
RadioButton attribute Any
ShrinkFlag attribute Any
Slider attribute Any
SpinBox attribute Any
TabWidget attribute Any
ToolButton attribute Any
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
controlType function (self) -> Any Returns the control type associated with the widget for which this size policy applies.
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
expandingDirections function (self) -> Any Returns whether a widget can make use of more space than the [QWidget::sizeHint](https://doc.qt.io/archives/qt-5.15/qwidget.html#sizeHint-prop)() function indicates.
hasHeightForWidth function (self) -> bool X.hasHeightForWidth() -> bool
hasWidthForHeight function (self) -> bool X.hasWidthForHeight() -> bool
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
horizontalPolicy function (self) -> Any Returns the horizontal component of the size policy.
horizontalStretch function (self) -> int X.horizontalStretch() -> int
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
readFrom function (self, arg__1: Any) -> Any (shared captured text)
retainSizeWhenHidden function (self) -> bool X.retainSizeWhenHidden() -> bool
setControlType function (self, type: Any) -> None Sets the control type associated with the widget for which this size policy applies to type.
setHeightForWidth function (self, b: bool) -> None Sets the flag determining whether the widget's preferred height depends on its width, to dependent.
setHorizontalPolicy function (self, d: Any) -> None Sets the horizontal component to the given policy.
setHorizontalStretch function (self, stretchFactor: int) -> None Sets the horizontal stretch factor of the size policy to the given stretchFactor. stretchFactor must be in the range \[0,255\].
setRetainSizeWhenHidden function (self, retainSize: bool) -> None Sets whether a layout should retain the widget's size when it is hidden.
setVerticalPolicy function (self, d: Any) -> None Sets the vertical component to the given policy.
setVerticalStretch function (self, stretchFactor: int) -> None Sets the vertical stretch factor of the size policy to the given stretchFactor. stretchFactor must be in the range \[0,255\].
setWidthForHeight function (self, b: bool) -> None Sets the flag determining whether the widget's width depends on its height, to dependent.
transpose function (self) -> None Swaps the horizontal and vertical policies and stretches.
verticalPolicy function (self) -> Any Returns the vertical component of the size policy.
verticalStretch function (self) -> int X.verticalStretch() -> int
writeTo function (self, arg__1: Any) -> Any (shared captured text)