C

GridLayout QML Type

Provides a way of dynamically arranging items in a grid. More...

Import Statement: import QtQuick.Layouts
Since: Qt Quick Ultralite 2.8
Inherits:

Item

Properties

Detailed Description

The GridLayout follows the behavior of the same QML type in Qt Quick Layouts. See the Qt Quick Layouts Overview for more details.

If the GridLayout is resized, all items in the layout will be rearranged. All visible children of the GridLayout element belong to the layout. If you want a layout with just one row or one column, you can use the RowLayout or ColumnLayout. These offer a bit more convenient API, and improve readability.

By default, items are arranged according to the flow property. The default value of the flow property is GridLayout.LeftToRight.

If the columns property is specified, it is treated as the maximum limit of how many columns the layout can have before the auto-positioning wraps back to the beginning of the next row.

Note: The columns property is only used when flow is GridLayout.LeftToRight.

The rows property works in a similar way, but items are auto-positioned vertically.

Note: The rows property is only used when flow is GridLayout.TopToBottom.

You can specify which cell you want an item to occupy by setting the Layout.row and Layout.column properties. You can also specify the row span or column span by setting the Layout.rowSpan or Layout.columnSpan properties.

Items in a GridLayout support these attached properties:

See also RowLayout and ColumnLayout.

Property Documentation

[default] columnSpacing : int

This property holds the spacing between each column.


columns : int

This property holds the column limit for items positioned if flow is GridLayout.LeftToRight. The default value is that there is no limit.


flow : enumeration

This property holds the flow direction of items that do not have an explicit cell position set. It is used together with the columns or rows property, which specify when flow is reset to the next row or column, respectively.

Possible values:

ConstantDescription
GridLayout.LeftToRightItems are positioned next to each other, then wrapped to the next line (default).
GridLayout.TopToBottomItems are positioned next to each other from top to bottom, then wrapped to the next column.

See also rows and columns.


layoutDirection : enumeration

This property holds the layout direction of the grid layout - it controls whether items are laid out from left to right or right to left. If Qt.RightToLeft is specified, left-aligned items will be right-aligned and right-aligned items will be left-aligned.

Possible values:

ConstantDescription
Qt.LeftToRightItems are laid out from left to right (default).
Qt.RightToLeftItems are laid out from right to left.

See also RowLayout::layoutDirection and ColumnLayout::layoutDirection.


[default] rowSpacing : int

This property holds the spacing between each row.


rows : int

This property holds the row limit for items positioned if flow is GridLayout.TopToBottom. The default value is that there is no limit.


Available under certain Qt licenses.
Find out more.