I downloaded the images & used the QML code from the OpacityMask documentation page (qt-project.org/doc/qt-5/qml-qtgraphicaleffects-opacitymask.html) but it isn’t doing what I expect. I though I would end up with a mostly red screen with a butterfly-shaped picture of a bug, but what I get instead is a boring square picture of a bug (on a red screen). There are no warnings in the console that would indicate the problem. Am I just mis-understanding the purpose of OpacityMask?
Thanks,
Chris
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtGraphicalEffects 1.0
Item
{
id: screen
anchors.fill: parent
Rectangle {
anchors.fill: parent
color: "red"
}
Item
{
id: hole
anchors.fill: parent
Image
{
id: bug
source:"qrc:/Bug.png"
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
}
Image
{
id: mask
source:"qrc:/Butterfly.png"
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
}
OpacityMask {
anchors.fill: bug
source: bug
maskSource: mask
}
}
}
[edit: added missing coding tags @ SGaist]
↧