Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Qt - OpacityMask does not work properly
Forum Updated to NodeBB v4.3 + New Features

Qt - OpacityMask does not work properly

Scheduled Pinned Locked Moved Brainstorm
3 Posts 2 Posters 5.6k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    Popa Raluca
    wrote on last edited by
    #1

    hi everyone ! i am new in Qt world so, please be nice :D

    i need to work in .qml, to apply a shader effect over just a part of an image;
    i tried something like this: i load an image, put a mask (a picture in black and white - white represents the aria where i want to apply the shader); i tried with OpacityMask but it does not work;

    the example from help does not work either : http://qt-project.org/doc/qt-5.0/qtgraphicaleffects/qml-qtgraphicaleffects1-opacitymask.html#example

    what am i missing ? any ideas ? thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      seyed
      wrote on last edited by
      #2

      Me too! HELP!

      1 Reply Last reply
      0
      • S Offline
        S Offline
        seyed
        wrote on last edited by
        #3

        I found the problem!
        Your mask object size must be same as source object.
        See a sample:
        @import QtQuick 2.1
        import QtGraphicalEffects 1.0

        Rectangle {
        id: root
        width: 600; height: 450
        Rectangle {
        id: sourceObj
        anchors.fill: parent
        Column {
        anchors.centerIn: parent
        rotation: -13
        Text {
        text: "Iran advancing science"
        font { family: "Segoe UI Light"; pixelSize: 32 }
        }
        Text {
        text: "Persia was a cradle of science in earlier times. "+"<br/>"+
        "Persia contributed to the current understanding of nature, "+"<br/>"+
        "medicine, mathematics, and philosophy. Persians made important "+"<br/>"+
        "contributions to algebra and chemistry, invented the wind-power "+"<br/>"+
        "machine, and the first distillation of alcohol. "
        font { family: "Segoe UI Light"; pixelSize: 12 }
        }
        }
        color: "skyblue"
        visible: false
        }
        Rectangle {
        id: maskObj
        color: "transparent" //Notice! i want to mask only non-transparent area!
        anchors.fill: sourceObj //Size must be same as sourceObj
        Rectangle {
        id: realMask //<----- This is my real mask
        width: 313; height: 72
        anchors.centerIn: parent
        color: "red"
        radius: 36
        }

            visible: false
        }
        OpacityMask {
            id: myEffect
            source: sourceObj
            maskSource: maskObj
            anchors.fill: parent
        }
        

        }
        @
        Good luck!

        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