Created
February 11, 2026 11:43
-
-
Save Gholamrezadar/838c16d7cc6428daba9448a691f78798 to your computer and use it in GitHub Desktop.
Rounded Image (Anti Aliasing Fixed) Component
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 | |
| Item { | |
| id: root | |
| // Alias for Image properties | |
| property alias source: img.source | |
| property alias fillMode: img.fillMode | |
| property alias asynchronous: img.asynchronous | |
| property alias cache: img.cache | |
| property alias mirror: img.mirror | |
| property alias sourceSize: img.sourceSize | |
| property alias status: img.status | |
| property alias progress: img.progress | |
| property alias paintedWidth: img.paintedWidth | |
| property alias paintedHeight: img.paintedHeight | |
| property real radius: 0 | |
| implicitWidth: img.implicitWidth | |
| implicitHeight: img.implicitHeight | |
| // Source Image (Invisible) | |
| Image { | |
| id: img | |
| anchors.fill: parent | |
| visible: false | |
| } | |
| // RoundedImage | |
| MultiEffect { | |
| anchors.fill: img | |
| source: img | |
| maskEnabled: true | |
| maskSource: mask | |
| // To fix the aliasing (src: https://forum.qt.io/topic/145956/rounded-image-in-qt6/10?_=1770808919853) | |
| maskThresholdMin: 0.5 | |
| maskSpreadAtMin: 1.0 | |
| } | |
| Item { | |
| id: mask | |
| width: img.width | |
| height: img.height | |
| layer.enabled: true | |
| layer.samples: 16 | |
| visible: false | |
| Rectangle { | |
| width: img.width | |
| height: img.height | |
| radius: root.radius | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment