Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. OpacityMask only works on Images?
QtWS25 Last Chance

OpacityMask only works on Images?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 681 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cscooper
    wrote on last edited by
    #1

    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
    }
    

    }
    @

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      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
      }
      

      }
      @

      157

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved