Last active
November 4, 2025 19:15
-
-
Save ramajd/fcbfbdfdfc3628d7d510c0d9c35558d3 to your computer and use it in GitHub Desktop.
Example of having rounded image corners in Qt6 (Alternative to Qt5's OpacityMask)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import QtQuick | |
| import QtQuick.Effects | |
| Window { | |
| width: 640 | |
| height: 480 | |
| visible: true | |
| title: qsTr("Hello World") | |
| Image { | |
| id: sourceItem | |
| source: "https://fastly.picsum.photos/id/727/300/300.jpg?hmac=kPiO13OlbcnHcQFJ0pIJpQhUZYUMz358Vvt0P-voCO4" | |
| anchors.centerIn: parent | |
| width: 300 | |
| height: 300 | |
| visible: false | |
| } | |
| MultiEffect { | |
| source: sourceItem | |
| anchors.fill: sourceItem | |
| maskEnabled: true | |
| maskSource: mask | |
| maskThresholdMin: 0.5 | |
| maskSpreadAtMin: 1.0 | |
| } | |
| Item { | |
| id: mask | |
| width: sourceItem.width | |
| height: sourceItem.height | |
| layer.enabled: true | |
| visible: false | |
| layer.smooth: true | |
| Rectangle { | |
| width: sourceItem.width | |
| height: sourceItem.height | |
| radius: 20 | |
| color: "black" | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment