Slider QML Type
用于通过沿轨道滑动手柄来选择数值。更多
Import Statement: | import QtQuick.Controls |
Inherits: |
属性
- from : real
- handle : Item
- horizontal : bool
(since QtQuick.Controls 2.3 (Qt 5.10))
- implicitHandleHeight : real
(since QtQuick.Controls 2.5 (Qt 5.12))
- implicitHandleWidth : real
(since QtQuick.Controls 2.5 (Qt 5.12))
- live : bool
(since QtQuick.Controls 2.2 (Qt 5.9))
- orientation : enumeration
- position : real
- pressed : bool
- snapMode : enumeration
- stepSize : real
- to : real
- touchDragThreshold : real
(since QtQuick.Controls 2.5 (Qt 5.12))
- value : real
- vertical : bool
(since QtQuick.Controls 2.3 (Qt 5.10))
- visualPosition : real
信号
- moved()
(since QtQuick.Controls 2.2 (Qt 5.9))
方法
详细说明
滑块用于通过沿轨道滑动手柄来选择数值。
在下面的示例中,设置了自定义from 、value 和to 值:
Slider { from: 1 value: 25 to: 100 }
position 属性表示为控件大小的一部分,范围为0.0 - 1.0
。visualPosition 属性与之相同,只是在从右到左的应用中相反。visualPosition 在为滑块设计样式时用于定位手柄。在上面的示例中,在从左到右的应用中,visualPosition 将是0.24
,而在从右到左的应用中,0.76
。
有关通过提供两个手柄让用户选择范围的滑块,请参阅RangeSlider 。
属性文档
horizontal : bool |
implicitHandleHeight : real |
该属性保存隐式句柄高度。
其值等于handle ? handle.implicitHeight : 0
。
它通常与implicitContentHeight 和implicitBackgroundHeight 一起用于计算implicitHeight 。
该属性在 QtQuick.Controls 2.5 (Qt 5.12) 中引入。
另请参阅 implicitHandleWidth 。
implicitHandleWidth : real |
该属性保存隐式句柄宽度。
其值等于handle ? handle.implicitWidth : 0
。
它通常与implicitContentWidth 和implicitBackgroundWidth 一起用于计算implicitWidth 。
该属性在 QtQuick.Controls 2.5 (Qt 5.12) 中引入。
另请参阅 implicitHandleHeight 。
live : bool |
orientation : enumeration |
position : real |
该属性用于保存句柄的逻辑位置。
位置表示为控件大小的一部分,范围为0.0 - 1.0
。为使滑块可视化,应使用从右到左的visualPosition 。
另请参阅 value,visualPosition, 和valueAt() 。
pressed : bool |
该属性显示滑块是通过触摸、鼠标还是按键按下的。
snapMode : enumeration |
touchDragThreshold : real |
该属性设置了触发触摸拖动事件的阈值(以逻辑像素为单位)。鼠标拖动阈值不受影响。默认值为Application.styleHints.startDragDistance
。
该属性在 QtQuick.Controls 2.5 (Qt 5.12) 中引入。
另请参阅 QStyleHints 。
vertical : bool |
visualPosition : real |
信号文档
|
当用户通过触摸、鼠标、滚轮或按键交互式移动滑块时,就会发出该信号。
注: 相应的处理程序是onMoved
。
此信号在 QtQuick.Controls 2.2 (Qt 5.9) 中引入。
方法文档
© 2025 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.