QtShadcn
组件

ShadcnSwitch

开关:44×20 / 28×16 双尺寸,胶囊轨道 + 滑块位移动画。

基于 QQC.Switch(Basic style),胶囊轨道 + 滑块位移动画。

用法

ShadcnSwitch { checked: true }                    // Default:44×20 轨道 + 24×16 滑块
ShadcnSwitch { size: ShadcnSwitch.Size.Small }    // Small:28×16 轨道 + 16×12 滑块
ShadcnSwitch { text: qsTr("通知"); checked: true }

视觉

  • checked:bg-primary + 2px primary 边框 + 滑块居右
  • unchecked:bg-input/90 + 透明边框 + 滑块居左
  • focus:3px 外环(与 Input 一致)
  • 滑块位移有动画(150ms)

相关

  • 表单开关场景(设置项、开关某功能)
  • 带文本时 QQC 自动布局 indicator + 文本
Copyright © 2026