Struct rute::auto::layout::Layout

source ·
pub struct Layout<'a> { /* private fields */ }
Expand description

Notice these docs are heavy WIP and not very relevent yet

This is an abstract base class inherited by the concrete classes QBoxLayout, QGridLayout, QFormLayout, and QStackedLayout.

For users of QLayout subclasses or of QMainWindow there is seldom any need to use the basic functions provided by QLayout, such as setSizeConstraint() or setMenuBar(). See Layout Management for more information.

To make your own layout manager, implement the functions addItem(), sizeHint(), setGeometry(), itemAt() and takeAt(). You should also implement minimumSize() to ensure your layout isn’t resized to zero size if there is too little space. To support children whose heights depend on their widths, implement hasHeightForWidth() and heightForWidth(). See the Border Layout and Flow Layout examples for more information about implementing custom layout managers.

Geometry management stops when the layout manager is deleted.

See also: LayoutItem {Layout Management} {Basic Layouts Example} {Border Layout Example} {Flow Layout Example}

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

Use setContentsMargins() and getContentsMargins() instead.

See also: [contents_rect()] spacing

If no value is explicitly set, the layout’s spacing is inherited from the parent layout, or from the style settings for the parent widget.

For QGridLayout and QFormLayout, it is possible to set different horizontal and vertical spacings using setHorizontalSpacing()

and setVerticalSpacing() . In that case, spacing() returns -1.

See also: [contents_rect()] [get_contents_margins()] [Style::layout_spacing] [Style::pixel_metric]

Sets the left, top, right, and bottom margins to use around the layout.

By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.

See also: [get_contents_margins()] [Style::pixel_metric] {QStyle::}{PM_LayoutLeftMargin} {QStyle::}{PM_LayoutTopMargin} {QStyle::}{PM_LayoutRightMargin} {QStyle::}{PM_LayoutBottomMargin}

Sets the margins to use around the layout.

By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.

See also: [contents_margins()]

Sets the left, top, right, and bottom margins to use around the layout.

By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.

See also: [get_contents_margins()] [Style::pixel_metric] {QStyle::}{PM_LayoutLeftMargin} {QStyle::}{PM_LayoutTopMargin} {QStyle::}{PM_LayoutRightMargin} {QStyle::}{PM_LayoutBottomMargin}

Sets the margins to use around the layout.

By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.

See also: [contents_margins()]

Extracts the left, top, right, and bottom margins used around the layout, and assigns them to * left, * top, * right, and * bottom (unless they are null pointers).

By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.

See also: [set_contents_margins()] [Style::pixel_metric] {QStyle::}{PM_LayoutLeftMargin} {QStyle::}{PM_LayoutTopMargin} {QStyle::}{PM_LayoutRightMargin} {QStyle::}{PM_LayoutBottomMargin}

Returns the layout’s geometry() rectangle, but taking into account the contents margins.

See also: [set_contents_margins()] [get_contents_margins()]

Sets the alignment for widget w to alignment and returns true if w is found in this layout (not including child layouts); otherwise returns false.

Overloads Sets the alignment for the layout l to alignment and returns true if l is found in this layout (not including child layouts); otherwise returns false.

Sets the alignment for widget w to alignment and returns true if w is found in this layout (not including child layouts); otherwise returns false.

Overloads Sets the alignment for the layout l to alignment and returns true if l is found in this layout (not including child layouts); otherwise returns false.

Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). All child widgets are placed below the bottom edge of the menu bar.

Returns the menu bar set for this layout, or 0 if no menu bar is set.

Returns the parent widget of this layout, or 0 if this layout is not installed on any widget.

If the layout is a sub-layout, this function returns the parent widget of the parent layout.

See also: [parent()]

Redoes the layout for parentWidget() if necessary.

You should generally not need to call this because it is automatically called at the most appropriate times. It returns true if the layout was redone.

See also: [update()] [Widget::update_geometry]

Updates the layout for parentWidget().

You should generally not need to call this because it is automatically called at the most appropriate times.

See also: [activate()] [invalidate()]

Adds widget w to this layout in a manner specific to the layout. This function uses addItem().

Implemented in subclasses to add an item. How it is added is specific to each subclass.

This function is not usually called in application code. To add a widget to a layout, use the addWidget() function; to add a child layout, use the addLayout() function provided by the relevant QLayout subclass.

Note: The ownership of item is transferred to the layout, and it’s the layout’s responsibility to delete it.

See also: [add_widget()] [BoxLayout::add_layout] [GridLayout::add_layout]

Removes the widget widget from the layout. After this call, it is the caller’s responsibility to give the widget a reasonable geometry or to put the widget back into a layout or to explicitly hide it if necessary.

Note: The ownership of widget remains the same as when it was added.

See also: [remove_item()] [Widget::set_geometry] [add_widget()]

Removes the layout item item from the layout. It is the caller’s responsibility to delete the item.

Notice that item can be a layout (since QLayout inherits QLayoutItem).

See also: [remove_widget()] [add_item()]

Returns whether this layout can make use of more space than sizeHint(). A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, whereas Qt::Vertical | Qt::Horizontal means that it wants to grow in both dimensions.

The default implementation returns Qt::Horizontal | Qt::Vertical. Subclasses reimplement it to return a meaningful value based on their child widgets’s size policies

See also: [size_hint()]

Returns the minimum size of this layout. This is the smallest size that the layout can have while still respecting the specifications.

The returned value doesn’t include the space required by QWidget::setContentsMargins() or menuBar().

The default implementation allows unlimited resizing.

Returns the maximum size of this layout. This is the largest size that the layout can have while still respecting the specifications.

The returned value doesn’t include the space required by QWidget::setContentsMargins() or menuBar().

The default implementation allows unlimited resizing.

Must be implemented in subclasses to return the layout item at index. If there is no such item, the function must return 0. Items are numbered consecutively from 0. If an item is deleted, other items will be renumbered.

This function can be used to iterate over a layout. The following code will draw a rectangle for each layout item in the layout structure of the widget.

See also: [count()] [take_at()]

Must be implemented in subclasses to remove the layout item at index from the layout, and return the item. If there is no such item, the function must do nothing and return 0. Items are numbered consecutively from 0. If an item is removed, other items will be renumbered.

The following code fragment shows a safe way to remove all items from a layout:

See also: [item_at()] [count()]

Searches for widget widget in this layout (not including child layouts).

Returns the index of widget, or -1 if widget is not found.

The default implementation iterates over all items using itemAt()

Must be implemented in subclasses to return the number of items in the layout.

See also: [item_at()]

Searches for widget from and replaces it with widget to if found. Returns the layout item that contains the widget from on success. Otherwise 0 is returned. If options contains Qt::FindChildrenRecursively (the default), sub-layouts are searched for doing the replacement. Any other flag in options is ignored.

Notice that the returned item therefore might not belong to this layout, but to a sub-layout.

The returned layout item is no longer owned by the layout and should be either deleted or inserted to another layout. The widget from is no longer managed by the layout and may need to be deleted or hidden. The parent of widget from is left unchanged.

This function works for the built-in Qt layouts, but might not work for custom layouts.

See also: [index_of()]

Enables this layout if enable is true, otherwise disables it.

An enabled layout adjusts dynamically to changes; a disabled layout acts as if it did not exist.

By default all layouts are enabled.

See also: [is_enabled()]

Returns true if the layout is enabled; otherwise returns false.

See also: [set_enabled()]

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.