Ask Your Question
0

Can a custom QML shape have a drop shadow applied to it?

asked 2023-06-26 07:25:07 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-26 07:53:01 +0000

scrum gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-26 07:25:07 +0000

Seen: 9 times

Last updated: Jun 26 '23