RangeSlider QML Type

Used to select a range of values by sliding two handles along a track. 更多...

Import Statement: import QtQuick.Controls 2.2
开始支持版本: Qt 5.7
基类:

Control

属性

方法

详细描述

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
  }

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.

参见 Customizing RangeSlider and Input Controls.

属性

first group

first.value : real

first.position : real

first.visualPosition : real

first.handle : Item

first.pressed : bool

first.hovered : bool

PropertyDescription
valueThis property holds the value of the first handle in the range from - to.

If to is greater than from, the value of the first handle must be greater than the second, and vice versa.

The default value is 0.0.

handleThis property holds the first handle item.
visualPositionThis property holds the visual position of the first handle.

The position is expressed as a fraction of the control's size, in the range 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.

positionThis property holds the logical position of the first handle.

The position is expressed as a fraction of the control's size, in the range 0.0 - 1.0. For visualizing a slider, the right-to-left aware visualPosition should be used instead.

pressedThis property holds whether the first handle is pressed.
hoveredThis property holds whether the first handle is hovered. This property was introduced in QtQuick.Controls 2.1.

参见 first.increase() and first.decrease().


from : real

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

参见 to, first.value, and second.value.


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 QML property was introduced in QtQuick.Controls 2.2.

参见 first.value and second.value.


orientation : enumeration

This property holds the orientation.

Possible values:

ConstantDescription
Qt.HorizontalHorizontal (default)
Qt.VerticalVertical

second group

second.value : real

second.position : real

second.visualPosition : real

second.handle : Item

second.pressed : bool

second.hovered : bool

PropertyDescription
valueThis property holds the value of the second handle in the range from - to.

If to is greater than from, the value of the first handle must be greater than the second, and vice versa.

The default value is 0.0.

handleThis property holds the second handle item.
visualPositionThis property holds the visual position of the second handle.

The position is expressed as a fraction of the control's size, in the range 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.

positionThis property holds the logical position of the second handle.

The position is expressed as a fraction of the control's size, in the range 0.0 - 1.0. For visualizing a slider, the right-to-left aware visualPosition should be used instead.

pressedThis property holds whether the second handle is pressed.
hoveredThis property holds whether the second handle is hovered. This property was introduced in QtQuick.Controls 2.1.

参见 second.increase() and second.decrease().


snapMode : enumeration

This property holds the snap mode.

Possible values:

ConstantDescription
RangeSlider.NoSnapThe slider does not snap (default).
RangeSlider.SnapAlwaysThe slider snaps while the handle is dragged.
RangeSlider.SnapOnReleaseThe 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.

参见 stepSize.


stepSize : real

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

参见 snapMode, first.increase(), and first.decrease().


to : real

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

参见 from, first.value, and second.value.


成员

void first.decrease()

Decreases the value of the handle by stepSize, or 0.1 if stepSize is not defined.

参见 first.


void first.increase()

Increases the value of the handle by stepSize, or 0.1 if stepSize is not defined.

参见 first.


void second.decrease()

Decreases the value of the handle by stepSize, or 0.1 if stepSize is not defined.

参见 second.


void second.increase()

Increases the value of the handle by stepSize, or 0.1 if stepSize is not defined.

参见 second.


void setValues(real 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.

参见 stepSize.