RangeSlider QML Type
Used to select a range of values by sliding two handles along a track. More...
Import Statement: | import QtQuick.Controls 2.14 |
Since: | Qt 5.7 |
Inherits: |
Properties
- first
- first.value : real
- first.position : real
- first.visualPosition : real
- first.handle : Item
- first.pressed : bool
- first.hovered : bool
- first.implicitHandleWidth : real
- first.implicitHandleHeight : real
- from : real
- horizontal : bool
- live : bool
- orientation : enumeration
- second
- second.value : real
- second.position : real
- second.visualPosition : real
- second.handle : Item
- second.pressed : bool
- second.hovered : bool
- second.implicitHandleWidth : real
- second.implicitHandleHeight : real
- snapMode : enumeration
- stepSize : real
- to : real
- touchDragThreshold : qreal
- vertical : bool
Signals
- void first.moved()
- void second.moved()
Methods
- void first.decrease()
- void first.increase()
- void second.decrease()
- void second.increase()
- void setValues(firstValue, real secondValue)
- real valueAt(position)
Detailed Description
RangeSlider is used to select a range specified by two values, by sliding each handle along a track.
In the example below, custom from and to values are set, and the initial positions of the first and second handles are set:
RangeSlider { from: 1 to: 100 first.value: 25 second.value: 75 }
In order to perform an action when the value for a particular handle changes, use the following syntax:
first.onMoved: console.log("first.value changed to " + first.value)
The first.position and second.position properties are expressed as fractions of the control's size, in the range 0.0 - 1.0
. The first.visualPosition and second.visualPosition properties are the same, except that they are reversed in a right-to-left application. The visualPosition
is useful for positioning the handles when styling RangeSlider. In the example above, first.visualPosition will be 0.24
in a left-to-right application, and 0.76
in a right-to-left application.
For a slider that allows the user to select a single value, see Slider.
See also Customizing RangeSlider, Input Controls, and Focus Management in Qt Quick Controls.
Property Documentation
Property | Description |
---|---|
value | This property holds the value of the first handle in the range from - to .If from is greater than to, the value of the first handle must be greater than the second, and vice versa. The default value is |
handle | This property holds the first handle item. |
visualPosition | This property holds the visual position of the first handle. The position is expressed as a fraction of the control's size, in the range |
position | This property holds the logical position of the first handle. The position is expressed as a fraction of the control's size, in the range |
pressed | This property holds whether the first handle is pressed by either touch, mouse, or keys. |
hovered | This property holds whether the first handle is hovered. This property was introduced in QtQuick.Controls 2.1. |
implicitHandleWidth | This property holds the implicit width of the first handle. This property was introduced in QtQuick.Controls 2.5. |
implicitHandleHeight | This property holds the implicit height of the first handle. This property was introduced in QtQuick.Controls 2.5. |
See also first.moved(), first.increase(), and first.decrease().
from : real |
This property holds the starting value for the range. The default value is 0.0
.
See also to, first.value, and second.value.
[read-only] horizontal : bool |
This property holds whether the slider is horizontal.
This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).
See also orientation.
live : bool |
This property holds whether the slider provides live updates for the first.value and second.value properties while the respective handles are dragged.
The default value is true
.
This property was introduced in QtQuick.Controls 2.2 (Qt 5.9).
See also first.value and second.value.
orientation : enumeration |
This property holds the orientation.
Possible values:
Constant | Description |
---|---|
Qt.Horizontal | Horizontal (default) |
Qt.Vertical | Vertical |
See also horizontal and vertical.
Property | Description |
---|---|
value | This property holds the value of the second handle in the range from - to .If from is greater than to, the value of the first handle must be greater than the second, and vice versa. The default value is |
handle | This property holds the second handle item. |
visualPosition | This property holds the visual position of the second handle. The position is expressed as a fraction of the control's size, in the range |
position | This property holds the logical position of the second handle. The position is expressed as a fraction of the control's size, in the range |
pressed | This property holds whether the second handle is pressed by either touch, mouse, or keys. |
hovered | This property holds whether the second handle is hovered. This property was introduced in QtQuick.Controls 2.1. |
implicitHandleWidth | This property holds the implicit width of the second handle. This property was introduced in QtQuick.Controls 2.5. |
implicitHandleHeight | This property holds the implicit height of the second handle. This property was introduced in QtQuick.Controls 2.5. |
See also second.moved(), second.increase(), and second.decrease().
snapMode : enumeration |
This property holds the snap mode.
The snap mode determines how the slider handles behave with regards to the stepSize.
Possible values:
Constant | Description |
---|---|
RangeSlider.NoSnap | The slider does not snap (default). |
RangeSlider.SnapAlways | The slider snaps while the handle is dragged. |
RangeSlider.SnapOnRelease | The slider does not snap while being dragged, but only after the handle is released. |
For visual explanations of the various modes, see the snapMode documentation of Slider.
See also stepSize.
stepSize : real |
This property holds the step size. The default value is 0.0
.
See also snapMode, first.increase(), and first.decrease().
to : real |
This property holds the end value for the range. The default value is 1.0
.
See also from, first.value, and second.value.
touchDragThreshold : qreal |
This property holds the threshold (in logical pixels) at which a touch drag event will be initiated. The mouse drag threshold won't be affected. The default value is Qt.styleHints.startDragDistance
.
This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).
See also QStyleHints.
[read-only] vertical : bool |
This property holds whether the slider is vertical.
This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).
See also orientation.
Signal Documentation
void first.moved() |
void second.moved() |
Method Documentation
void first.decrease() |
void first.increase() |
void second.decrease() |
void second.increase() |
void setValues(firstValue, real secondValue) |
Sets first.value and second.value with the given arguments.
If to is larger than from and firstValue is larger than secondValue, firstValue will be clamped to secondValue.
If from is larger than to and secondValue is larger than firstValue, secondValue will be clamped to firstValue.
This function may be necessary to set the first and second values after the control has been completed, as there is a circular dependency between firstValue and secondValue which can cause assigned values to be clamped to each other.
See also stepSize.
real valueAt(position) |
Returns the value for the given position.
This method was introduced in QtQuick.Controls 2.5 (Qt 5.12).
See also first.value, second.value, first.position, second.position, and live.
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.