I want to create a rectangle with inner shadow in QML
, something similar with what Photoshop
does:
QML
has InnerShadow
but I'm unable to achieve this effect. The closest I got was this
import QtQuick 2.0
import QtGraphicalEffects 1.0
Item {
id: root
width: 300
height: 300
Rectangle {
id: myRectangle
anchors.centerIn: parent
width: 100
height: 100
color: "grey"
}
InnerShadow {
anchors.fill: root
cached: true
horizontalOffset: 0
verticalOffset: 0
radius: 16
samples: 32
color: "#b0000000"
smooth: true
source: root
}
}
which is an idea I got from this post. However this example only works if root
has a significantly bigger size than myRectangle
and I don't want that. I need e.g. a 200x10
square in which shadow is uniformly spread across the edges of the rectangle. I tried all kinds of values for the InnerShadow
properties but I couldn't get even close to the effect I want.
Can this be achieved using QML
?