On this page

C

Slider QML Type

Used to select a value by sliding a handle along a track. More...

Import Statement: import QtQuick.Controls
Since: Qt Quick Ultralite 1.0
Inherits:

Control

Enumerations

Properties

Signals

Methods

Detailed Description

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

In the example below, custom from, value, and to values are set:

Slider {
    from: 1
    value: 25
    to: 100
}

The position property is expressed as a fraction of the control's size, in the range 0.0 - 1.0. The visualPosition is useful for positioning the handle when styling Slider.

See also Controls Styling and Input Controls.

Enumeration Documentation

SnapMode

Provides a list of slider snap modes to choose from.

ConstantDescription
Slider.NoSnapThe slider does not snap (default).
Slider.SnapAlwaysThe slider snaps while the handle is dragged.
Slider.SnapOnReleaseThe slider does not snap while being dragged, but it snaps after the handle is released.

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 Controls Styling.


horizontal : bool [read-only]

This property holds whether the slider is horizontal.

See also orientation.


orientation : Qt::Orientation

This property holds the orientation.

See also horizontal and vertical.


position : real [read-only]

This property holds the logical position of the handle.

The position is expressed as a fraction of the control's size, in the range 0.0 - 1.0.

See also value, visualPosition, and valueAt().


pressed : bool

This property holds whether the slider is pressed by either touch, mouse, or keys.


snapMode : SnapMode

This property holds the snap mode.

The snap mode determines how the slider handle behaves with regards to the stepSize.

In the following table, the various modes are illustrated with animations. The movement of the mouse cursor and the stepSize (0.2) are identical in each animation.

ValueExample
Slider.NoSnap

Slider.SnapAlways

Slider.SnapOnRelease

See also stepSize.


stepSize : real

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


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.

See also position.


vertical : bool [read-only]

This property holds whether the slider is vertical.

See also orientation.


visualPosition : real [read-only]

This property holds the visual position of the handle.

See also position.


Signal Documentation

moved()

This signal is emitted when the slider has been interactively moved by the user.

Note: The corresponding handler is onMoved.


Method Documentation

real valueAt(real position)

Returns the value for the given position.

See also value and position.


Available under certain Qt licenses.
Find out more.