Struct rute::auto::grid_layout::GridLayout
source · pub struct GridLayout<'a> { /* private fields */ }
Expand description
Notice these docs are heavy WIP and not very relevent yet
QGridLayout takes the space made available to it (by its parent layout or by the parentWidget()), divides it up into rows and columns, and puts each widget it manages into the correct cell.
Columns and rows behave identically; we will discuss columns, but there are equivalent functions for rows.
Each column has a minimum width and a stretch factor. The minimum width is the greatest of that set using setColumnMinimumWidth() and the minimum width of each widget in that column. The stretch factor is set using setColumnStretch() and determines how much of the available space the column will get over and above its necessary minimum.
Normally, each managed widget or layout is put into a cell of its own using addWidget(). It is also possible for a widget to occupy multiple cells using the row and column spanning overloads of addItem() and addWidget(). If you do this, QGridLayout will guess how to distribute the size over the columns/rows (based on the stretch factors).
To remove a widget from a layout, call removeWidget(). Calling QWidget::hide() on a widget also effectively removes the widget from the layout until QWidget::show() is called.
This illustration shows a fragment of a dialog with a five-column, three-row grid (the grid is shown overlaid in magenta):
Columns 0, 2 and 4 in this dialog fragment are made up of a QLabel, a QLineEdit, and a QListBox. Columns 1 and 3 are placeholders made with setColumnMinimumWidth(). Row 0 consists of three QLabel objects, row 1 of three QLineEdit objects and row 2 of three QListBox objects. We used placeholder columns (1 and 3) to get the right amount of space between the columns.
Note that the columns and rows are not equally wide or tall. If you want two columns to have the same width, you must set their minimum widths and stretch factors to be the same yourself. You do this using setColumnMinimumWidth() and setColumnStretch().
If the QGridLayout is not the top-level layout (i.e. does not manage all of the widget’s area and children), you must add it to its parent layout when you create it, but before you do anything with it. The normal way to add a layout is by calling addLayout() on the parent layout.
Once you have added your layout you can start putting widgets and other layouts into the cells of your grid layout using addWidget(), addItem(), and addLayout().
QGridLayout also includes two margin widths: the contents margin and the spacing(). The contents margin is the width of the reserved space along each of the QGridLayout’s four sides. The spacing() is the width of the automatically allocated spacing between neighboring boxes.
The default contents margin values are provided by the style . The default value Qt styles specify is 9 for child widgets and 11 for windows. The spacing defaults to the same as the margin width for a top-level layout, or to the same as the parent layout.
See also: [BoxLayout
]
[StackedLayout
]
{Layout Management}
{Basic Layouts 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
sourceimpl<'a> GridLayout<'a>
impl<'a> GridLayout<'a>
pub fn new() -> GridLayout<'a>
pub fn set_horizontal_spacing(&self, spacing: i32) -> &Self
sourcepub fn horizontal_spacing(&self) -> i32
pub fn horizontal_spacing(&self) -> i32
If no value is explicitly set, the layout’s horizontal spacing is inherited from the parent layout, or from the style settings for the parent widget.
See also: verticalSpacing
[Style::pixel_metric
]
{QStyle::}{PM_LayoutHorizontalSpacing}
pub fn set_vertical_spacing(&self, spacing: i32) -> &Self
sourcepub fn vertical_spacing(&self) -> i32
pub fn vertical_spacing(&self) -> i32
If no value is explicitly set, the layout’s vertical spacing is inherited from the parent layout, or from the style settings for the parent widget.
See also: horizontalSpacing
[Style::pixel_metric
]
{QStyle::}{PM_LayoutHorizontalSpacing}
sourcepub fn set_spacing(&self, spacing: i32) -> &Self
pub fn set_spacing(&self, spacing: i32) -> &Self
This function sets both the vertical and horizontal spacing to spacing.
See also: [set_vertical_spacing()
]
[set_horizontal_spacing()
]
sourcepub fn spacing(&self) -> i32
pub fn spacing(&self) -> i32
If the vertical spacing is equal to the horizontal spacing, this function returns that value; otherwise it return -1.
See also: [set_spacing()
]
[vertical_spacing()
]
[horizontal_spacing()
]
sourcepub fn set_row_minimum_height(&self, row: i32, min_size: i32) -> &Self
pub fn set_row_minimum_height(&self, row: i32, min_size: i32) -> &Self
Sets the minimum height of row row to minSize pixels.
See also: [row_minimum_height()
]
[set_column_minimum_width()
]
sourcepub fn set_column_minimum_width(&self, column: i32, min_size: i32) -> &Self
pub fn set_column_minimum_width(&self, column: i32, min_size: i32) -> &Self
Sets the minimum width of column column to minSize pixels.
See also: [column_minimum_width()
]
[set_row_minimum_height()
]
sourcepub fn row_minimum_height(&self, row: i32) -> i32
pub fn row_minimum_height(&self, row: i32) -> i32
Returns the minimum width set for row row.
See also: [set_row_minimum_height()
]
sourcepub fn column_minimum_width(&self, column: i32) -> i32
pub fn column_minimum_width(&self, column: i32) -> i32
Returns the column spacing for column column.
See also: [set_column_minimum_width()
]
sourcepub fn column_count(&self) -> i32
pub fn column_count(&self) -> i32
Returns the number of columns in this grid.
sourcepub fn cell_rect(&self, row: i32, column: i32) -> Rect<'_>
pub fn cell_rect(&self, row: i32, column: i32) -> Rect<'_>
Returns the geometry of the cell with row row and column column in the grid. Returns an invalid rectangle if row or column is outside the grid.
Warning: in the current version of Qt this function does not return valid results until setGeometry() has been called, i.e. after the parentWidget() is visible.
sourcepub fn add_widget<W: WidgetTrait<'a>>(&self, w: &W) -> &Self
pub fn add_widget<W: WidgetTrait<'a>>(&self, w: &W) -> &Self
Adds the given widget to the cell grid at row, column. The top-left position is (0, 0) by default.
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
Overloads This version adds the given widget to the cell grid, spanning multiple rows/columns. The cell will start at fromRow, fromColumn spanning rowSpan rows and columnSpan columns. The widget will have the given alignment.
If rowSpan and/or columnSpan is -1, then the widget will extend to the bottom and/or right edge, respectively.
sourcepub fn add_widget_row_column<W: WidgetTrait<'a>>(
&self,
arg0: &W,
row: i32,
column: i32,
arg1: Alignment
) -> &Self
pub fn add_widget_row_column<W: WidgetTrait<'a>>(
&self,
arg0: &W,
row: i32,
column: i32,
arg1: Alignment
) -> &Self
Adds the given widget to the cell grid at row, column. The top-left position is (0, 0) by default.
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
Overloads This version adds the given widget to the cell grid, spanning multiple rows/columns. The cell will start at fromRow, fromColumn spanning rowSpan rows and columnSpan columns. The widget will have the given alignment.
If rowSpan and/or columnSpan is -1, then the widget will extend to the bottom and/or right edge, respectively.
sourcepub fn add_widget_row_column_span<W: WidgetTrait<'a>>(
&self,
arg0: &W,
row: i32,
column: i32,
row_span: i32,
column_span: i32,
arg1: Alignment
) -> &Self
pub fn add_widget_row_column_span<W: WidgetTrait<'a>>(
&self,
arg0: &W,
row: i32,
column: i32,
row_span: i32,
column_span: i32,
arg1: Alignment
) -> &Self
Adds the given widget to the cell grid at row, column. The top-left position is (0, 0) by default.
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
Overloads This version adds the given widget to the cell grid, spanning multiple rows/columns. The cell will start at fromRow, fromColumn spanning rowSpan rows and columnSpan columns. The widget will have the given alignment.
If rowSpan and/or columnSpan is -1, then the widget will extend to the bottom and/or right edge, respectively.
sourcepub fn add_layout<L: LayoutTrait<'a>>(
&self,
arg0: &L,
row: i32,
column: i32,
arg1: Alignment
) -> &Self
pub fn add_layout<L: LayoutTrait<'a>>(
&self,
arg0: &L,
row: i32,
column: i32,
arg1: Alignment
) -> &Self
Places the layout at position ( row, column) in the grid. The top-left position is (0, 0).
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
A non-zero alignment indicates that the layout should not grow to fill the available space but should be sized according to sizeHint().
layout becomes a child of the grid layout.
Overloads This version adds the layout layout to the cell grid, spanning multiple rows/columns. The cell will start at row, column spanning rowSpan rows and columnSpan columns.
If rowSpan and/or columnSpan is -1, then the layout will extend to the bottom and/or right edge, respectively.
sourcepub fn add_layout_2<L: LayoutTrait<'a>>(
&self,
arg0: &L,
row: i32,
column: i32,
row_span: i32,
column_span: i32,
arg1: Alignment
) -> &Self
pub fn add_layout_2<L: LayoutTrait<'a>>(
&self,
arg0: &L,
row: i32,
column: i32,
row_span: i32,
column_span: i32,
arg1: Alignment
) -> &Self
Places the layout at position ( row, column) in the grid. The top-left position is (0, 0).
The alignment is specified by alignment. The default alignment is 0, which means that the widget fills the entire cell.
A non-zero alignment indicates that the layout should not grow to fill the available space but should be sized according to sizeHint().
layout becomes a child of the grid layout.
Overloads This version adds the layout layout to the cell grid, spanning multiple rows/columns. The cell will start at row, column spanning rowSpan rows and columnSpan columns.
If rowSpan and/or columnSpan is -1, then the layout will extend to the bottom and/or right edge, respectively.
sourcepub fn set_origin_corner(&self, arg0: Corner) -> &Self
pub fn set_origin_corner(&self, arg0: Corner) -> &Self
Sets the grid’s origin corner, i.e. position (0, 0), to corner.
sourcepub fn origin_corner(&self) -> Corner
pub fn origin_corner(&self) -> Corner
Returns the corner that’s used for the grid’s origin, i.e. for position (0, 0).
sourcepub fn item_at_position(&self, row: i32, column: i32) -> Option<LayoutItem<'_>>
pub fn item_at_position(&self, row: i32, column: i32) -> Option<LayoutItem<'_>>
Returns the layout item that occupies cell ( row, column), or 0 if the cell is empty.
See also: [get_item_position()
]
[index_of()
]
pub fn count(&self) -> i32
pub fn set_default_positioning(&self, n: i32, orient: Orientation) -> &Self
pub fn set_custom_event<F>(&self, func: F) -> &Selfwhere
F: Fn(&Event<'_>) + 'a,
pub fn build(&self) -> Self
Trait Implementations
sourceimpl<'a> Clone for GridLayout<'a>
impl<'a> Clone for GridLayout<'a>
sourcefn clone(&self) -> GridLayout<'a>
fn clone(&self) -> GridLayout<'a>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more