Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, a custom QML shape can have a drop shadow applied to it. This can be achieved by using the DropShadow element in QML.

Here's an example:

import QtQuick 2.12
import QtGraphicalEffects 1.12

Item {
    width: 100
    height: 100

    Rectangle {
        id: myShape
        width: parent.width
        height: parent.height
        color: "red"
    }

    DropShadow {
        anchors.fill: myShape
        horizontalOffset: 10
        verticalOffset: 10
        radius: 10
        color: "black"
        samples: 20
    }
}

In this example, we define an Item and add a custom Rectangle shape inside it. We then add a DropShadow element that fills the entire myShape rectangle and applies a drop shadow effect. The horizontalOffset, verticalOffset, radius, color, and samples properties can all be adjusted to achieve the desired effect.