ShadowStyle QML Type
定义委托的阴影样式。更多
| Import Statement: | import Qt.labs.StyleKit |
属性
- blur : real
- color : color
- delegate : Component
- horizontalOffset : real
- opacity : real
- scale : real
- verticalOffset : real
- visible : bool
详细说明
ShadowStyle 提供了在DelegateStyle 后面渲染阴影的属性。它可作为shadow 分组属性用于任何委托。
button { background { shadow { color: "lightgray" opacity: 0.6 verticalOffset: 2 horizontalOffset: 2 } } }
通过调整比例和颜色,阴影还可用于创建发光效果。下面的代码段为Switch 的句柄添加了漫射白色光晕,选中时会增强:
dark: Theme { applicationWindow.background.color: "#1e1e1e" switchControl { handle.color: "white" handle.shadow { color: "ghostwhite" scale: 1.2 opacity: 0.6 } checked.handle.shadow.scale: 1.5 } }
注意: Qt.labs 模块中的类型不保证在未来版本中保持兼容。
另请参阅 DelegateStyle,ControlStyle,ControlStateStyle 和FallbackStyle 参考。
属性文档
blur : real
阴影的模糊程度。0.0 的值会产生锐利的阴影,而较大的值则会产生较柔和、较分散的阴影。默认值为10.0 。
color : color
阴影的颜色。默认值是transparent ,这意味着默认情况下不会绘制阴影。
delegate : Component
自定义 QMLComponent ,用于替代默认阴影渲染。设置后,StyleKit 会实例化该组件,而不是绘制默认阴影。
horizontalOffset : real
阴影与代表的水平偏移量,单位为像素。
opacity : real
阴影的不透明度,从0.0 (完全透明)到1.0 (完全不透明)。默认值为1.0 。
scale : real
阴影相对于委托的比例因子。默认值为1.0 。
verticalOffset : real
阴影与委托的垂直偏移量,单位为像素。
visible : bool
阴影是否可见。默认值是true 。
但是,由于默认阴影color 是transparent ,除非设置不同的颜色,否则阴影将不可见。
另请参阅 opacity 。
© 2026 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.