RectangularGlow QML Type
生成一个模糊且上色的矩形,给人一种源对象正在发光的感觉。更多...
| Import Statement: | import Qt5Compat.GraphicalEffects |
| Since: | QtGraphicalEffects 1.0 |
| Inherits: |
属性
- cached : bool
- color : color
- cornerRadius : real
- glowRadius : real
- spread : real
详细说明
此效果旨在提供良好的性能表现。光晕的形状仅限于带有自定义圆角半径的矩形。若需要自定义形状,请考虑使用“Glow ”效果。
| 已应用的效果 |
|---|
|
示例
以下示例演示了如何应用该效果。
import QtQuick
import Qt5Compat.GraphicalEffects
Item {
width: 300
height: 300
Rectangle {
id: background
anchors.fill: parent
color: "black"
}
RectangularGlow {
id: effect
anchors.fill: rect
glowRadius: 10
spread: 0.2
color: "white"
cornerRadius: rect.radius + glowRadius
}
Rectangle {
id: rect
color: "black"
anchors.centerIn: parent
width: Math.round(parent.width / 1.5)
height: Math.round(parent.height / 2)
radius: 25
}
}属性文档
cached : bool
此属性允许将效果输出像素缓存起来,以提升渲染性能。
每次更改源或效果属性时,都必须更新缓存中的像素。由于需要额外的内存缓冲区来存储效果输出,因此内存消耗会增加。
当源或效果属性被动画化时,建议禁用缓存。
默认情况下,该属性设置为false 。
color : color
此属性定义了用于生成光晕效果的 RGBA 颜色值。
默认情况下,该属性设置为"white" 。
| 使用不同颜色值的输出示例 | ||
|---|---|---|
|
|
|
| color: #ffffff | color: #55ff55 | color: #5555ff |
| glowRadius: 20 | glowRadius: 20 | glowRadius: 20 |
| spread: 0 | spread: 0 | spread: 0 |
| cornerRadius: 25 | cornerRadius: 25 | cornerRadius: 25 |
cornerRadius : real
此属性定义了用于绘制带圆角光效的圆角半径。
其取值范围为 0.0 到光晕有效宽度或高度的一半,以较小者为准。可通过以下公式计算:min(width, height) / 2.0 + glowRadius
默认情况下,该属性与glowRadius 属性绑定。当调整glowRadius 属性时,光晕的效果就如同该矩形被模糊处理一般。
| 不同 cornerRadius 值的输出示例 | ||
|---|---|---|
|
|
|
| cornerRadius: 0 | cornerRadius: 25 | cornerRadius: 50 |
| glowRadius: 20 | glowRadius: 20 | glowRadius: 20 |
| spread: 0 | spread: 0 | spread: 0 |
| color: #ffffff | color: #ffffff | color: #ffffff |
glowRadius : real
该属性定义了光晕会延伸到项目区域外多少像素。
该值的取值范围为 0.0(无光晕)到 inf(无限光晕)。默认情况下,该属性设置为0.0 。
| 不同 glowRadius 值的输出示例 | ||
|---|---|---|
|
|
|
| glowRadius: 10 | glowRadius: 20 | glowRadius: 40 |
| spread: 0 | spread: 0 | spread: 0 |
| color: #ffffff | color: #ffffff | color: #ffffff |
| cornerRadius: 25 | cornerRadius: 25 | cornerRadius: 25 |
spread : real
此属性定义了在光源边缘附近,发光颜色被增强的程度。
该值的取值范围为 0.0(不增强)到 1.0(最大增强)。默认情况下,该属性设置为0.0 。
| 不同扩散值下的输出示例 | ||
|---|---|---|
|
|
|
| spread:0.0 | spread: 0.5 | spread: 1.0 |
| glowRadius: 20 | glowRadius: 20 | glowRadius: 20 |
| color: #ffffff | color: #ffffff | color: #ffffff |
| cornerRadius: 25 | cornerRadius: 25 | cornerRadius: 25 |
© 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.












