Qt Reference Documentation

QML ScrollBar Element

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

Inherits Item

  • List of all members, including inherited members
  • 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

     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 }
         }
     }

    Anchoring 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: vertical
             flickableItem: grid
             orientation: Qt.Horizontal
             anchors { left: grid.left; bottom: grid.bottom }
         }
     }

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

    Property Documentation

    read-onlyflickableItem : 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.


    read-onlyinteractive : 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.


    read-onlyorientation : int

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

    The default value is Qt.Vertical.


    read-onlypolicy : int

    The policy are 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.