RangeSlider QML 類型

用於通過沿軌道滑動 2 手柄來選擇值範圍。 更多...

import 語句: import QtQuick.Controls 2.15
Since: Qt 5.7
繼承:

Control

特性

信號

方法

詳細描述

RangeSlider is used to select a range specified by two values, by sliding each handle along a track.

在以下範例中,自定義 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 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 將是 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 .

另請參閱 Customizing RangeSlider , 輸入控件 ,和 Focus Management in Qt Quick Controls .

特性文檔編製

first group

first.handle : Item

first.hovered : bool

first.implicitHandleHeight : real

first.implicitHandleWidth : real

first.position : real

first.pressed : bool

first.value : real

first.visualPosition : real

特性 描述
This property holds the value of the first handle in the range from - to .

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

默認值為 0.0 .

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

位置

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 0.0 - 1.0 . For visualizing a slider, the right-to-left aware visualPosition 應該被使用以取而代之。

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.

另請參閱 first.moved() , first.increase() ,和 first.decrease() .

from : real

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

另請參閱 to , first.value ,和 second.value .

[read-only] horizontal : bool

This property holds whether the slider is horizontal.

該特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。

另請參閱 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.

默認值為 true .

This property was introduced in QtQuick.Controls 2.2 (Qt 5.9).

另請參閱 first.value and second.value .

orientation : enumeration

This property holds the orientation.

可能的值:

常量 描述
Qt.Horizontal Horizontal (default)
Qt.Vertical Vertical

另請參閱 horizontal and vertical .

second group

second.handle : Item

second.hovered : bool

second.implicitHandleHeight : real

second.implicitHandleWidth : real

second.position : real

second.pressed : bool

second.value : real

second.visualPosition : real

特性 描述
This property holds the value of the second handle in the range from - to .

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

默認值為 0.0 .

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

位置

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 0.0 - 1.0 . For visualizing a slider, the right-to-left aware visualPosition 應該被使用以取而代之。

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.

另請參閱 second.moved() , second.increase() ,和 second.decrease() .

snapMode : enumeration

此特性保持捕捉方式。

The snap mode determines how the slider handles behave with regards to the stepSize .

可能的值:

常量 描述
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 .

另請參閱 stepSize .

stepSize : real

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

另請參閱 snapMode , first.increase() ,和 first.decrease() .

to : real

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

另請參閱 from , first.value ,和 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 .

該特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。

另請參閱 QStyleHints .

[read-only] vertical : bool

This property holds whether the slider is vertical.

該特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。

另請參閱 orientation .

信號文檔編製

void first.moved ()

void second.moved ()

This signal is emitted when either the first or second handle has been interactively moved by the user by either touch, mouse, or keys.

This QML signal was introduced in QtQuick.Controls 2.5.

另請參閱 first and second .

方法文檔編製

void first.decrease ()

Decreases the value of the handle by stepSize ,或 0.1 if stepSize 未定義。

另請參閱 first .

void first.increase ()

Increases the value of the handle by stepSize ,或 0.1 if stepSize 未定義。

另請參閱 first .

void second.decrease ()

Decreases the value of the handle by stepSize ,或 0.1 if stepSize 未定義。

另請參閱 second .

void second.increase ()

Increases the value of the handle by stepSize ,或 0.1 if stepSize 未定義。

另請參閱 second .

void setValues ( real firstValue , real secondValue )

設置 first.value and second.value with the given arguments.

to > from and firstValue > secondValue , firstValue will be clamped to secondValue.

from > 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 .

real valueAt ( real position )

Returns the value for the given position .

This method was introduced in QtQuick.Controls 2.5 (Qt 5.12).

另請參閱 first.value , second.value , first.position , second.position ,和 live .

版權所有  © 2014-2026 樂數軟件    

工業和信息化部: 粵ICP備14079481號-1