Slider

Slider is a component to select a value from a continuous range of values. More...

Import Statement: import Ubuntu.Components 1.1
Inherits:

StyledItem

Properties

Signals

Methods

Detailed Description

The slider's sensing area is defined by the width and height, therefore styles should take this into account when defining the visuals, and alter these values to align the graphics' sizes.

See also the Design Guidelines on Sliders.

Example:

Item {
    Slider {
        function formatValue(v) { return v.toFixed(2) }
        minimumValue: -3.14
        maximumValue: 3.14
        value: 0.0
        live: true
    }
}

Property Documentation

activeFocusOnPress : bool

The property specifies whether the StyledItem can gain focus on a mouse press/touch or not. When the value is true, the focus will be set on the component when the mouse is pressed over it or touched. However if one of the component's ancestor StyledItem or derived is having the property value false, the focus will not be gained automatically.

In the following example the TextField will stay focused when clicked on the red rectangle.

import QtQuick 2.2
import Ubuntu.Components 1.1

Column {
    width: units.gu(50)
    height: units.gu(100)

    StyledItem {
        objectName: "passiveScope"
        width: parent.width
        height: units.gu(30)
        Rectangle {
            anchors.fill: parent
            color: "red"
            StyledItem {
                objectName: "activeScope"
                activeFocusOnPress: true
                anchors.fill: parent
            }
        }
    }

    TextField {
        id: input
        text: "The input stays focus even if red box is clicked"
    }

    Component.onCompleted: input.forceActiveFocus()

    Connections {
        target: window
        onActiveFocusItemChanged: console.debug("focus on", window.activeFocusItem)
    }
}

The default value is false.

This QML property was introduced in Ubuntu.Components 1.1.


live : bool

This QML property is under development and is subject to change.

Defines whether the value is updated while the thumb is dragged or just when the thumb is released.


maximumValue : real

This QML property is under development and is subject to change.

The maximum value from the continuous range of values. If this value is lesser than minimumValue, the component will be in an inconsistent state.


minimumValue : real

This QML property is under development and is subject to change.

The minimum value from the continuous range of values. If this value is greater than maximumValue, the component will be in an inconsistent state.


pressed : bool

This QML property is under development and is subject to change.

Whether the Slider is currently being pressed.


style : Component

Component instantiated immediately and placed below everything else.


value : real

This QML property is under development and is subject to change.

The current value of the slider. This property is not changed while the thumb is dragged unless the live property is set to true.


Signal Documentation

touched(bool onThumb)

This QML signal is under development and is subject to change.

The signal is emitted when there is a click on the slider. The onThumb parameter provides information if the click, was inside of the thumb element.


Method Documentation

formatValue( v)

This QML method is under development and is subject to change.

This function is used by the value indicator to show the current value. Reimplement this function if you want to show different information. By default, the value v is rounded to the nearest interger value.