From 93b25dfa97494184493e02b75766e57bc6fe79bb Mon Sep 17 00:00:00 2001 From: Erik Prabowo Kamal Date: Fri, 12 Dec 2025 17:51:38 +0800 Subject: Reimplement Qt5 OpacityMask using Qt6 MultiEffect https://darapsa.org/qessenger.git/commit/?id=5f777bca13beadd0a56d2264225b0c09e49541a2 The mask Rectangle needs to be put outside of the MultiEffect, and referred to by the Rectangle's ID. It wouldn't work if it's put directly on MultiEffect's maskSource. https://forum.qt.io/topic/145956/rounded-image-in-qt6 Enabling layer and invisibility on the mask rectangle are a must. Take notice on what Jacoco wrote about jagged edges at the end of the thread. Will test that later. --- Header.ui.qml | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'Header.ui.qml') diff --git a/Header.ui.qml b/Header.ui.qml index d903b2a..3b19cfb 100644 --- a/Header.ui.qml +++ b/Header.ui.qml @@ -2,6 +2,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import Qt5Compat.GraphicalEffects +import QtQuick.Effects import Bootstrap import Eduport import "DropShadow" as DrpShdw @@ -99,14 +100,19 @@ ToolBar { } layer { enabled: true - effect: OpacityMask { - maskSource: Rectangle { - width: 40 - height: 40 - radius: 40 - } + effect: MultiEffect { + maskEnabled: true + maskSource: maskRectangle } } + Rectangle { + id: maskRectangle + width: 40 + height: 40 + radius: 40 + layer.enabled: true + visible: false + } contentItem: Item { Image { @@ -214,14 +220,19 @@ ToolBar { } layer { enabled: true - effect: OpacityMask { - maskSource: Rectangle { - width: imageWidth - height: imageHeight - radius: maskRadius - } + effect: MultiEffect { + maskEnabled: true + maskSource: maskRectangle } } + Rectangle { + id: maskRectangle + width: imageWidth + height: imageHeight + radius: maskRadius + layer.enabled: true + visible: false + } } } -- cgit v1.2.3