Skip to content

Instantly share code, notes, and snippets.

@mitchcurtis
Created July 2, 2018 06:40
Show Gist options
  • Save mitchcurtis/56e3de5c45e0ce137f24e7d981cd6271 to your computer and use it in GitHub Desktop.
Save mitchcurtis/56e3de5c45e0ce137f24e7d981cd6271 to your computer and use it in GitHub Desktop.
OpacityMask cutout
import QtQuick 2.0
import QtQuick.Window 2.0
import QtGraphicalEffects 1.0
Window {
id: window
width: 400
height: 400
visible: true
Flickable {
id: flickable
width: 100
height: 100
contentWidth: content.implicitWidth
contentHeight: content.implicitHeight
anchors.centerIn: parent
Rectangle {
id: content
width: 128
height: 128
color: "steelblue"
}
}
Rectangle {
id: bg
anchors.fill: parent
color: "#aa000000"
visible: false
}
Item {
id: cutout
anchors.fill: parent
visible: false
Rectangle {
width: flickable.width
height: flickable.height
anchors.centerIn: parent
}
}
OpacityMask {
anchors.fill: bg
source: bg
maskSource: cutout
invert: true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment