Used to select a value by sliding a handle along a track. 更多...
| import 語句: | import QtQuick.Controls 2.5 |
| 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.
For a slider that allows the user to select a range by providing two handles, see RangeSlider .
另請參閱 Customizing Slider and 輸入控件 .
|
from : real |
This property holds the starting value for the range. The default value is
0.0
.
|
handle : Item |
This property holds the handle item.
另請參閱 Customizing Slider .
|
[read-only] horizontal : bool |
This property holds whether the slider is horizontal.
該特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。
另請參閱 orientation .
|
[read-only] implicitHandleHeight : real |
This property holds the implicit handle height.
值等於
handle ? handle.implicitHeight : 0
.
This is typically used, together with implicitContentHeight and implicitBackgroundHeight , to calculate the implicitHeight .
該特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另請參閱 implicitHandleWidth .
|
[read-only] implicitHandleWidth : real |
This property holds the implicit handle width.
值等於
handle ? handle.implicitWidth : 0
.
This is typically used, together with implicitContentWidth and implicitBackgroundWidth , to calculate the implicitWidth .
該特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另請參閱 implicitHandleHeight .
|
live : bool |
This property holds whether the slider provides live updates for the value property while the handle is dragged.
默認值為
true
.
This property was introduced in QtQuick.Controls 2.2 (Qt 5.9).
|
orientation : enumeration |
This property holds the orientation.
可能的值:
| 常量 | 描述 |
|---|---|
Qt.Horizontal
|
Horizontal (default) |
Qt.Vertical
|
Vertical |
另請參閱 horizontal and 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 by either touch, mouse, or keys.
|
snapMode : enumeration |
此特性保持捕捉方式。
The snap mode determines how the slider handle behaves with regards to the stepSize .
可能的值:
| 常量 | 描述 |
|---|---|
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
.
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 .
|
value : real |
This property holds the value in the range
from
-
to
。默認值為
0.0
.
另請參閱 position .
|
[read-only] vertical : bool |
This property holds whether the slider is vertical.
該特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。
另請參閱 orientation .
|
[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 .
This signal is emitted when the slider has been interactively moved by the user by either touch, mouse, wheel, or keys.
This signal was introduced in QtQuick.Controls 2.2 (Qt 5.9).
Decreases the value by
stepSize
or
0.1
if
stepSize
未定義。
另請參閱 stepSize .
Increases the value by
stepSize
or
0.1
if
stepSize
未定義。
另請參閱 stepSize .
Returns the value for the given position .
This method was introduced in QtQuick.Controls 2.1 (Qt 5.8).