pub struct SizePolicy<'a> { /* private fields */ }
Expand description

Notice these docs are heavy WIP and not very relevent yet

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.

See also: Size Widget::size_hint Widget::size_policy() LayoutItem::size_hint

Licence

The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.

Implementations

Returns the horizontal component of the size policy.

See also: [set_horizontal_policy()] [vertical_policy()] [horizontal_stretch()]

Returns the vertical component of the size policy.

See also: [set_vertical_policy()] [horizontal_policy()] [vertical_stretch()]

Sets the horizontal component to the given policy.

See also: [horizontal_policy()] [set_vertical_policy()] [set_horizontal_stretch()]

Sets the vertical component to the given policy.

See also: [vertical_policy()] [set_horizontal_policy()] [set_vertical_stretch()]

Returns whether a widget can make use of more space than the QWidget::sizeHint() function indicates.

A value of Qt::Horizontal or Qt::Vertical means that the widget can grow horizontally or vertically (i.e., the horizontal or vertical policy is Expanding or MinimumExpanding),,) whereas Qt::Horizontal | Qt::Vertical means that it can grow in both dimensions.

See also: [horizontal_policy()] [vertical_policy()]

Sets the flag determining whether the widget’s preferred height depends on its width, to dependent.

See also: [has_height_for_width()] [set_width_for_height()]

Returns true if the widget’s preferred height depends on its width; otherwise returns false.

See also: [set_height_for_width()]

Sets the flag determining whether the widget’s width depends on its height, to dependent.

This is only supported for QGraphicsLayout’s subclasses. It is not possible to have a layout with both height-for-width and width-for-height constraints at the same time.

See also: [has_width_for_height()] [set_height_for_width()]

Returns true if the widget’s width depends on its height; otherwise returns false.

See also: [set_width_for_height()]

Returns whether the layout should retain the widget’s size when it is hidden. This is false by default.

See also: [set_retain_size_when_hidden()]

Sets whether a layout should retain the widget’s size when it is hidden. If retainSize is true, the layout will not be changed by hiding the widget.

See also: [retain_size_when_hidden()]

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.