Qt Reference Documentation

QML Slider Element

Lets the user select a value within a fixed range by sliding the handle. More...

This element was introduced in Qt Quick Components 1.0.

Properties

Signal Handlers

Detailed Description

The range is set by the slider's minimumValue and maximumValue. The value is incremented using the stepSize property. If the minimumValue is 0, the maximumValue is 100, and the stepSize value is 40, the possible Slider values are 0, 40, 80, and 100. All the numeric values of the slider are floating point values.

When the user slides the handle, the value is updated and the valueChanged signal is emitted . If the valueIndicatorVisible property is true, the value indicator is shown beside the handle when the user presses the handle. The value indicator shows the text of valueIndicatorText, but if valueIndicatorText contains an empty string, the indicator shows the current value instead.

Setting Up a Slider

In the code snippet below the slider's maximum, minimum, and current values are set as well as the step size. The valueIndicatorVisible property is set to true.

 Slider {
     maximumValue: 150
     minimumValue: -150
     value: 150
     stepSize: 50
     valueIndicatorVisible: true
 }

In the the screenshot below the slider's value is shown on the value indicator.

A vertical slider is configured by setting the property orientation to Qt.Vertical. This slider also has a visible value indicator and the inverted property is set to true, so the minimum value is at the bottom of the slider. The value of the valueIndicatorText property is Volume.

 Slider {
     orientation: Qt.Vertical
     maximumValue: 25
     stepSize: 1
     value: 25
     valueIndicatorVisible: true
     valueIndicatorText: "Volume"
     inverted: true
 }

When the user drags the slider's handle, the value indicator shows the text Volume.

Property Documentation

inverted : bool

Inverts the progression of the slider. When false, the positive progression is from left to right or top to bottom. Setting the property to true will switch the progression from right to left or bottom to top.

The default value is false.


maximumValue : real

The maximum value of the slider's range. The default value is 1.


minimumValue : real

The minimum value of the slider's range. The default value is 0.


orientation : int

The orientation of the slider. Use Qt.Horizontal for left-right sliding and Qt.Vertical for up-down sliding. The default value is Qt.Horizontal.


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.


pressed : bool

While the user presses and holds the slider handle, the pressed value is true; otherwise false.


stepSize : real

The size of the step between the minimum and maximum values. The default value is 0.


value : real

The current value of the slider. The position of the slider's handle indicates graphically the current value. The default value is 0.


valueIndicatorText : string

If valueIndicatorText is an empty string, the slider's value will be displayed when the user drags the slider handle. If valueIndicatorText contains a non-empty string value, that value is shown when the user drags the slider handle. The value indicator is shown only if the valueIndicatorVisible is true and the user presses the slider handle; otherwise the value indicator is not shown. The default value is an empty string.

See also valueIndicatorVisible.


valueIndicatorVisible : bool

Controls whether the value indicator is visible when the user presses the slider handle. The value indicator is shown only when the valueIndicatorVisible property is true and the user presses the slider handle; otherwise the value indicator is not visible. The default value is false.

See also valueIndicatorText.


Signal Handler Documentation

Slider::valueChanged ()

This signal is emitted when the value of the slider changes.