SwitchDelegate QML Type

带有开关指示器的项目委托,可以打开或关闭。更多

Import Statement: import QtQuick.Controls
Inherits:

ItemDelegate

属性

详细说明

SwitchDelegate 展示了一个可以打开(选中)或关闭(取消选中)的项目委托。Switch 委托通常用于从一组选项中选择一个或多个选项。对于较小的选项集或需要唯一标识的选项,可考虑使用Switch 代替。

SwitchDelegate 的 API 继承自ItemDelegate ,而 又继承自AbstractButton 。例如,您可以设置text ,并使用AbstractButton API 对clicks 做出反应。开关委托的状态可通过checked 属性设置。

ListView {
    model: ["Option 1", "Option 2", "Option 3"]
    delegate: SwitchDelegate {
        text: modelData
    }
}

另请参阅 自定义 SwitchDelegate委托控件

属性文档

position : real [read-only]

该属性保存拇指指示器的逻辑位置。

位置以指示器大小的一部分表示,范围为0.0 -1.0 。例如,该位置可用于确定拇指是否已拖过半点。要实现拇指指示器的可视化,应使用从右到左的感知visualPosition

另请参阅 visualPosition


visualPosition : real [read-only]

该属性用于保存拇指指示器的可视化位置。

该位置以指示器大小的一部分表示,范围为0.0 -1.0 。当控件为mirrored 时,该值等于1.0 - position 。因此,考虑到从右到左的支持,该值适用于拇指指示器的可视化。例如,为了确定拇指是否已拖过半点,应使用逻辑position

另请参见 position


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