Slider QML Type

Used to select a value by sliding a handle along a track. 更多...

import 语句: import QtQuick.Controls 2.2
Since: Qt 5.7
继承: Control

特性

信号

方法

详细描述

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

在以下范例中,自定义 from , value ,和 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 visualPosition property is the same, except that it is reversed in a right-to-left application. The visualPosition is useful for positioning the handle when styling Slider. In the example above, visualPosition 将是 0.24 in a left-to-right application, and 0.76 in a right-to-left application.

另请参阅 Customizing Slider and 输入控件 .

特性文档编制

from : real

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

另请参阅 to and value .

handle : Item

This property holds the handle item.

另请参阅 Customizing Slider .

live : bool

This property holds whether the slider provides live updates for the value property while the handle is dragged.

默认值为 true .

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

另请参阅 value and valueAt() .

orientation : enumeration

This property holds the orientation.

可能的值:

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

[read-only] position : real

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

另请参阅 value , visualPosition ,和 valueAt() .

pressed : bool

This property holds whether the slider is pressed.

snapMode : enumeration

This property holds the snap mode.

可能的值:

常量 描述
Slider.NoSnap The slider does not snap (default).
Slider.SnapAlways The slider snaps while the handle is dragged.
Slider.SnapOnRelease The slider does not snap while being dragged, but only after the handle is released.

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.

范例
Slider.NoSnap
Slider.SnapAlways
Slider.SnapOnRelease

另请参阅 stepSize .

stepSize : real

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

另请参阅 snapMode , increase() ,和 decrease() .

to : real

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

另请参阅 from and value .

value : real

This property holds the value in the range from - to 。默认值为 0.0 .

另请参阅 position .

[read-only] visualPosition : real

This property holds the visual position of the 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.

另请参阅 position .


信号文档编制

void moved ()

This signal is emitted when the slider has been interactively moved by the user by either touch, mouse, wheel, or keys.

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


方法文档编制

void decrease ()

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

另请参阅 stepSize .

void increase ()

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

另请参阅 stepSize .

real valueAt ( real position )

Returns the value for the given position .

This QML method was introduced in QtQuick.Controls 2.1 (Qt 5.8).

另请参阅 value and position .