Vic*_*voy 4 javascript qt effects qml
是否可以模糊其他项目背后的项目?
示例:模糊图像的一部分(如qml中 - parent.centerIn:image)

我想要的东西:
Image { id: img
anchors.fill: parent
source: "bug.png"
Item { id: info
anchors.centerIn: parent
height: 200
width: 200
Text {
text: "HAMMER TIME"
color: "white"
}
/* BLUR CODE HERE TO BLUR BACKGROUND OF THIS ITEM */
/* which is a part of "bug.png" image with 200x200 size */
/* and offset equals to "info.x" and "info.y" */
}
}
Run Code Online (Sandbox Code Playgroud)
这个问题影响到任何问题,shader effect因为官方文档没有问题的答案,我的所有尝试都没有成功 - 只能模糊整个项目而不是它的一部分.
这是我的解决方案.此版本仅适用于矩形.Item ShaderEffectSource有助于创建这样的源矩形.
import QtQuick 2.3
import QtQuick.Window 2.2
import QtGraphicalEffects 1.0
Window {
visible: true
width: 600
height:600
Image {
id: image_bug
anchors.fill: parent
source: "images/Original_bug.png"
}
ShaderEffectSource {
id: effectSource
sourceItem: image_bug
anchors.centerIn: image_bug
width: 400
height: 400
sourceRect: Qt.rect(x,y, width, height)
}
FastBlur{
id: blur
anchors.fill: effectSource
source: effectSource
radius: 100
}
}
Run Code Online (Sandbox Code Playgroud)
如果您需要其他形状,我认为您可能需要应用蒙版着色器,首先剪切相关部分然后应用模糊.