Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-63105

Shapes do not work with OpacityMask if invisible

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.10.1
    • 5.10
    • Quick: Other
    • None
    • Not a Qt 5.10.1 release blocker -> Removed from blocker list
    • ebba7d790efff51e51b8b4d9342ffb47f1310b48

    Description

      It seems that the items that are used in OpacityMasks which contain shapes have to be visible, or else the shapes are like if they do not exist.

      In the code below, the color of the triangle is purple, a combination of the source item's blue and mask's red, indicating that masking works ( Both b and the opacity mask are visible, and the opacity mask overlaps the shape of b).
      However changing b.visible into false will result in nothing displayed, while, as per documentation (http://doc.qt.io/qt-5/qml-qtgraphicaleffects-opacitymask.html), items used in the mask are supposed to be not visible.

      import QtQuick 2.4
      import QtQuick.Window 2.4
      import QtGraphicalEffects 1.0
      import QtQuick.Shapes 1.0
      
      Window {
          visible: true
          width: 640
          height: 480
          id: root
          color: "green"
      
          Item {
              id: i
              width: parent.width * 0.2
              height: width
              anchors.right: parent.right
              anchors.top: parent.top
      
              Rectangle {
                  id: a
                  visible: false
                  anchors.fill: parent
                  color: 'blue'
              }
      
              Rectangle {
                  id: b
                  anchors.fill: parent
                  color: "transparent"
                  visible: true
      
                  Shape {
                      id: c
                      vendorExtensionsEnabled: false
      
                      ShapePath {
                          id: c_sp
                          strokeWidth: -1
                          fillColor: Qt.rgba(1,0,0,0.5)
      
                          property point center: Qt.point(b.x + b.width * 0.5 , b.y + b.height * 0.5)
                          property real quarter: b.width * 0.25
      
      
                          property point top: Qt.point(center.x, center.y - quarter )
                          property point bottomLeft: Qt.point(center.x - quarter, center.y + quarter )
                          property point bottomRight: Qt.point(center.x + quarter, center.y + quarter )
      
                          startX: center.x;
                          startY: center.y + quarter
      
                          PathLine { x: c_sp.bottomLeft.x; y: c_sp.bottomLeft.y }
                          PathLine { x: c_sp.top.x; y: c_sp.top.y }
                          PathLine { x: c_sp.bottomRight.x; y: c_sp.bottomRight.y }
                          PathLine { x: c_sp.center.x; y: c_sp.center.y + c_sp.quarter }
                      }
                  }
              }
      
      
              OpacityMask {
                  visible: true
                  anchors.fill: a
                  source: a
                  maskSource: b
                  invert: false
              }
          }
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              lagocs Laszlo Agocs
              paangele Paolo Angelelli
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes