Qt 5.7 | Qt Quick Controls 2 | QML Types | Slider QML Type

Qt 5.7.1 Reference Documentation

# Slider QML Type

Selects a value by sliding a handle along a track. More...

Import Statement: | import QtQuick.Controls 2.0
Since: | Qt 5.7
Inherits: | Control

- List of all members, including inherited members

## Properties

- from : real
- handle : Item
- orientation : enumeration
- position : real
- pressed : bool
- snapMode : enumeration
- stepSize : real
- to : real
- value : real
- visualPosition : real

## Methods

- void decrease()
- void increase()

## Detailed Description

Slider is used to select a value by sliding a handle along a track.

| A slider in its normal state.
| A slider that has active focus.
| A slider that is disabled.

      Slider {
          value: 0.5
      }

See also Customizing Slider and Input Controls.

## Property Documentation

from : real

This property holds the starting value for the range. The default value is `0.0`.

See also to and value.

handle : Item

This property holds the handle item.

See also Customizing Slider.

orientation : enumeration

This property holds the orientation.

Possible values:

Constant | Description
--- | ---
`Qt.Horizontal` | Horizontal (default)
`Qt.Vertical` | Vertical

[read-only] position : real

This property holds the logical position of the handle.

The position is defined as a percentage of the control's size, scaled to `0.0 - 1.0`. Unlike the value property, the `position` is continuously updated while the handle is dragged. For visualizing a slider, the right-to-left aware visualPosition should be used instead.

See also value and visualPosition.

pressed : bool

This property holds whether the slider is pressed.

snapMode : enumeration

This property holds the snap mode.

Possible values:

Constant | Description
--- | ---
`Slider.NoSnap` | The slider does not snap (default).
`Slider.SnapAlways` | The slider snaps while the handle is dragged.
`Slider.SnapOnRelease` | The slider does not snap while being dragged, but only after the handle is released.

See also stepSize.

stepSize : real

This property holds the step size. The default value is `0.0`.

See also snapMode, increase(), and decrease().

to : real

This property holds the end value for the range. The default value is `1.0`.

See also from and value.

value : real

This property holds the value in the range `from` - `to`. The default value is `0.0`.

Unlike the position property, the `value` is not updated while the handle is dragged. The value is updated after the value has been chosen and the slider has been released.

See also position.

[read-only] visualPosition : real

This property holds the visual position of the handle.

The position is defined as a percentage of the control's size, scaled to `0.0 - 1.0`. When the control is mirrored, the value is equal to `1.0 - position`. This makes the value suitable for visualizing the slider, taking right-to-left support into account.

See also position.

## Method Documentation

void decrease()

Decreases the value by stepSize or `0.1` if stepSize is not defined.

See also stepSize.

void increase()

Increases the value by stepSize or `0.1` if stepSize is not defined.

See also stepSize.