ZoomBlur QML Type
对源项的中心点应用定向模糊效果。更多...
| Import Statement: | import Qt5Compat.GraphicalEffects |
| Since: | Qt5Compat.GraphicalEffects 1.0 |
| Inherits: |
属性
- cached : bool
- horizontalOffset : real
- length : real
- samples : int
- source : variant
- transparentBorder : bool
- verticalOffset : real
详细说明
该效果会营造出源对象似乎正在沿Z轴方向向中心点移动,或者摄像机似乎正在快速变焦的视觉效果。其他可用的运动模糊效果包括DirectionalBlur 和RadialBlur 。
| 源 | 已应用的效果 |
|---|---|
|
|
注意:此 效果仅在使用 OpenGL 运行时可用。
示例
以下示例展示了如何应用该效果。
import QtQuick
import Qt5Compat.GraphicalEffects
Item {
width: 300
height: 300
Image {
id: butterfly
source: "images/bug.jpg"
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
}
ZoomBlur {
anchors.fill: butterfly
source: butterfly
samples: 24
length: 48
}
}属性文档
cached : bool
此属性允许将效果输出像素缓存起来,以提升渲染性能。
每次更改源或效果属性时,缓存中的像素都必须更新。由于需要额外的内存缓冲区来存储效果输出,因此内存消耗会增加。
当源或效果属性被动画化时,建议禁用缓存。
默认情况下,该属性设置为false 。
horizontalOffset : real
这些属性定义了模糊方向中心点的像素偏移量。
取值范围为 -inf 到 inf。默认情况下,这些属性设置为0 。
| 不同 horizontalOffset 值下的输出示例 | ||
|---|---|---|
|
|
|
| horizontalOffset:100.0 | horizontalOffset:0.0 | horizontalOffset:-100.0 |
| samples: 24 | samples: 24 | samples: 24 |
| length: 32 | length: 32 | length: 32 |
| verticalOffset: 0 | verticalOffset: 0 | verticalOffset: 0 |
length : real
此属性定义了每个像素所能感知到的最大位移量。该数值在中心附近较小,并在边缘处达到指定值。
模糊效果的质量取决于samples 属性。如果length值较大,则需要更多的采样点才能保持较高的视觉质量。
该值的取值范围为 0.0 到 inf。默认情况下,该属性设置为0.0 (无模糊)。
| 不同长度值下的输出示例 | ||
|---|---|---|
|
|
|
| length:0.0 | length: 32.0 | length:48.0 |
| samples: 24 | samples: 24 | samples: 24 |
| horizontalOffset: 0 | horizontalOffset: 0 | horizontalOffset: 0 |
| verticalOffset: 0 | verticalOffset: 0 | verticalOffset: 0 |
samples : int
该属性定义了在进行模糊计算时,每个像素会采样多少次。数值越大,质量越高,但渲染速度越慢。
该属性不适用于动画效果。更改此属性可能会导致底层 OpenGL 着色器被重新编译。
允许的取值范围为 0 到 inf(实际最大值取决于 GPU)。默认情况下,该属性设置为0 (不进行采样)。
source : variant
此属性用于指定将被模糊处理的源项目。
注意: 不支持让效果包含其自身,例如将“源”设置为该效果的父级。
transparentBorder : bool
该属性定义了项目边缘附近的模糊行为,此时像素的模糊效果会受到源边缘外部像素的影响。
如果将该属性设置为true ,则源区域外的像素将被解释为透明,这类似于 OpenGL 的“clamp-to-border”扩展。模糊效果会稍微扩展到效果项区域之外。
如果将该属性设置为false ,则源区域外的像素将被解释为与项目边缘像素具有相同的颜色,这类似于 OpenGL 的“clamp-to-edge”行为。模糊效果不会扩展到效果项目区域之外。
默认情况下,该属性设置为false 。
verticalOffset : real
这些属性定义了模糊方向中心点的像素偏移量。
取值范围为 -inf 到 inf。默认情况下,这些属性设置为0 。
| 不同horizontalOffset 值下的输出示例 | ||
|---|---|---|
|
|
|
| horizontalOffset :100.0 | horizontalOffset: 0.0 | horizontalOffset: -100.0 |
| samples: 24 | samples: 24 | samples: 24 |
| length: 32 | length: 32 | length: 32 |
| 垂直偏移量:0 | 垂直偏移量:0 | 垂直偏移量:0 |
© 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.







