Switch QML Type
可打开或关闭的开关按钮。更多
Import Statement: | import QtQuick.Controls |
Inherits: |
属性
- position : real
- visualPosition : real
详细说明
开关是一个选项按钮,可以拖动或切换为打开(选中)或关闭(未选中)。开关通常用于在两种状态之间进行选择。对于较大的选项集(如列表中的选项),可考虑使用SwitchDelegate 代替。
Switch 的 API 继承自AbstractButton 。例如,开关的状态可以通过checked 属性来设置。当用户通过触摸、鼠标或键盘交互式点击开关时,将发出clicked 和AbstractButton::toggled 信号。
ColumnLayout { Switch { text: qsTr("Wi-Fi") checked: Networking.wifiEnabled onClicked: Networking.wifiEnabled = checked } Switch { text: qsTr("Bluetooth") checked: Networking.bluetoothEnabled onClicked: Networking.bluetoothEnabled = checked } }
属性文档
position : real |
该属性保存拇指指示器的逻辑位置。
位置以指示器大小的分数表示,范围为0.0
-1.0
。例如,该位置可用于确定拇指是否已拖过半点。要实现拇指指示器的可视化,应使用从右到左的感知visualPosition 。
另请参阅 visualPosition 。
visualPosition : real |
© 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.