OpacityMask only works on Images?



  • I have the OpacityMask working fine when I apply it to an Image, but if I try to apply it to a Rectangle it has no effect (and no warnings or errors in the console). Is this a known limitation of the effect?

    Thanks,
    Chris

    @import QtQuick 2.0
    import QtGraphicalEffects 1.0

    Item {
    width: 300
    height: 300

    /*
    Image {
        id: bug
        source: "qrc:/AimingWidget.png"
        sourceSize: Qt.size(parent.width, parent.height)
        smooth: true
        visible: false
    }
    */
    Rectangle
    {
        id: bug
        width: parent.width
        height: parent.height
        color: "blue"
    }
    
    Image {
        id: mask
        source: "qrc:/Mask.png"
        sourceSize: Qt.size(parent.width, parent.height)
        // smooth: true
        visible:false
        width: parent.width
        height: parent.height
    }
    
    OpacityMask {
        anchors.fill: bug
        source: bug
        maskSource: mask
    }
    

    }
    @


  • Moderators

    Hi,

    It does work. You are putting in wrong source and maskSource. Try this
    @
    import QtQuick 2.0
    import QtGraphicalEffects 1.0

    Item {
    width: 300
    height: 300

    Rectangle
    {
        id: bug
        width: parent.width
        height: parent.height
        color: "blue"
        radius: width/2
    }
    
    Image {
        id: mask
        source: "http://qt.digia.com/Global/About Us/Qt_master_logo_CMYK_300dpi.png"
        sourceSize: Qt.size(parent.width, parent.height)
        visible:false
        width: parent.width
        height: parent.height
    }
    
    OpacityMask {
        anchors.fill: mask
        source: mask
        maskSource: bug
    }
    

    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.