Row Element Reference

The Row item arranges its children horizontally.

[Inherits Item]

This element was introduced in Qt 4.7.

Detailed Description

The Row item arranges its children horizontally.

The Row item positions its child items so that they are horizontally aligned and not overlapping.

Use spacing to set the spacing between items in a Row, and use the add and move properties to set the transitions that should be applied when items are added to, removed from, or re-positioned within the Row.

See Using QML Positioner and Repeater Items for more details about this item and other related items.

Example Usage

The following example lays out differently shaped rectangles using a Row.

  1. import QtQuick 1.0
  2.  
  3. Row  {
  4.     spacing: 2
  5.     Rectangle  { color: "red"; width: 50; height: 50 }
  6.     Rectangle  { color: "green"; width: 20; height: 50 }
  7.     Rectangle  { color: "blue"; width: 50; height: 20 }
  8. }

Using Transitions

Transitions can be used to animate items that are added to, moved within, or removed from a Grid item. The add and move properties can be set to the transitions that will be applied when items are added to, removed from, or re-positioned within a Row item.

Limitations

Note that the positioner assumes that the x and y positions of its children will not change. If you manually change the x or y properties in script, bind the x or y properties, use anchors on a child of a positioner, or have the width of a child depend on the position of a child, then the positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Row.

Items with a width or height of 0 will not be positioned.

Properties

Property Documentation

This property holds the transition to be applied when adding an item to the positioner. The transition will only be applied to the added item(s). Positioner transitions will only affect the position (x, y) of items.

For a positioner, adding an item can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible.

See also move.

This property holds the layoutDirection of the row.

Possible values:

  • Qt.LeftToRight (default) - Items are laid out from left to right. If the width of the row is explicitly set, the left anchor remains to the left of the row.
  • Qt.RightToLeft - Items are laid out from right to left. If the width of the row is explicitly set, the right anchor remains to the right of the row.

When using the attached property LayoutMirroring::enabled for locale layouts, the visual layout direction of the row positioner will be mirrored. However, the property layoutDirection will remain unchanged. You can use the property LayoutMirroring::enabled to determine whether the direction has been mirrored.

This property group was introduced in QtQuick 1.1.

See also Grid::layoutDirection, Flow::layoutDirection, Layout directions example, and LayoutMirroring.

This property holds the transition to be applied when moving an item within the positioner. Positioner transitions will only affect the position (x, y) of items.

This transition can be performed when other items are added or removed from the positioner, or when items resize themselves.

  1.                 Row  {
  2.     id: positioner
  3.     move: Transition  {
  4.         NumberAnimation  {
  5.             properties: "x"
  6.             ease: "easeOutBounce"
  7.         }
  8.     }
  9. }

See also add and Positioners example.

  • spacing : int

The spacing is the amount in pixels left empty between adjacent items. The default spacing is 0.

See also Grid::spacing.

Notes provided by the Qt Community

No notes