Qt Reference Documentation

QML ScrollBar Element

Adds a visual indication of the position and interaction of the contents in a Flickable element. More...

This element was introduced in Qt Quick Components 1.0.

Properties

Methods

Detailed Description

A ScrollBar can be used with Flickable items as well as items derived from it, such as ListView and GridView items. ScrollBar should be a sibling of the Flickable. However, because ScrollBar is not a child of the Flickable, it has to be explicitly anchored to the Flickable.

Note: Both ScrollBar and ScrollDecorator components display bars to a Flickable item, but the ScrollDecorator is already anchored to the Flickable item.

ScrollBar Usage

The code snippet below illustrates how to attach a ScrollBar to a ListView.

 Item {
     x: 10
     width: 400
     anchors.top: parent.top
     anchors.bottom: parent.bottom

     ListView {
         id: list
         anchors.fill: parent
         ...
     }

     ScrollBar {
         flickableItem: list
         anchors { right: list.right; top: list.top }
     }
 }

The code snippet below illustrates how to anchor a horizontal ScrollBar to a GridView.

 Item {
     x: 10
     width: 400
     anchors.top: parent.top
     anchors.bottom: parent.bottom

     GridView {
         id: grid
         anchors.fill: parent
         ...
     }

     ScrollBar {
         id: horizontal
         flickableItem: grid
         orientation: Qt.Horizontal
         anchors { left: grid.left; bottom: grid.bottom }
     }
 }

See also ScrollDecorator, Flickable, Flickable, GridView, ListView, and ScrollDecorator.

Property Documentation

flickableItem : Flickable

The Flickable to which the Scrollbar is anchored.

If the value is not set, the scroll bar is not shown.

The default value of the property is null.


interactive : bool

If interactive is true, the user can move the flickableItem content by touching and dragging the scroll bar handle. If interactive is false, the scroll bar is indicative, that is, similar to a ScrollDecorator. Setting the interactive to false does not affect the key navigation support of ScrollBar that can be defined with Item::focus.

The default value is true.


orientation : int

The orientation of the scroll bar, either Qt.Vertical, or Qt.Horizontal.

The default value is Qt.Vertical.


platformInverted : bool

Symbian:

If platformInverted is true, the component is visualized with the inverted style. For more information, see Using Inverted Style with Symbian Components. By default platformInverted is false.

This property group was introduced in Qt Quick Components 1.1.


policy : int

Defines the situations when the scroll bar is shown. A scroll bar can have the following policies:

  • Symbian.ScrollBarWhenScrolling - the scroll bar is shown when the user scrolls a Flickable or drags and starts hideout. This policy inherits the Symbian.ScrollBarWhenNeeded policy.
  • Symbian.ScrollBarWhenNeeded - Scroll bar is shown when the content of flickableItem does not fit in the screen.

The default value is Symbian.ScrollBarWhenScrolling.

See also flash().


Method Documentation

ScrollBar::flash ()

Shows and then hides the scroll bar indicating to the user that there is scrollable content available in flickableItem. This method is most applicable when the policy is Symbian.ScrollBarWhenScrolling and the scroll bar is already hidden.