From 1bbfda315505d8a75fa005cf5798232ec5e2dede Mon Sep 17 00:00:00 2001 From: Mehran Dehghanian Date: Tue, 4 May 2021 14:49:48 +0430 Subject: [PATCH] Add 'Clip round rectangles' --- Clip-round-rectangles.md | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Clip-round-rectangles.md diff --git a/Clip-round-rectangles.md b/Clip-round-rectangles.md new file mode 100644 index 0000000..d9a6319 --- /dev/null +++ b/Clip-round-rectangles.md @@ -0,0 +1,53 @@ +### Using the clip property to crop child objects inside Item or Rectangle +https://evileg.com/en/post/577/ + +### Short Version + +``` +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtGraphicalEffects 1.0 + +Item{ + id: root + + width: parent.width + height: parent.height + + Rectangle{ + id: itemDelegate + width: 300 + height: 96 + color: "#1aebebeb" + radius: height/4 + border.color: "#9de000" + clip: true + + layer.enabled: true + layer.effect: OpacityMask { + maskSource: Item { + width: itemDelegate.width + height: itemDelegate.height + Rectangle { + anchors.centerIn: parent + width: itemDelegate.width + height: itemDelegate.height + radius: itemDelegate.radius + } + } + } + + Rectangle{ + width: parent.width*0.25 + height: parent.height + color: "#9de000" + } + + Row{ + width: parent.width + height: parent.height + } + } +} + +``` \ No newline at end of file