[Interest] Draw a shadow around a Rectangle using DropShadow. Should be possible, right?

Mark Gaiser markg85 at gmail.com
Thu Feb 6 12:59:06 CET 2014


On Thu, Feb 6, 2014 at 11:33 AM, Sze Howe Koh <szehowe.koh at gmail.com> wrote:
> On 5 February 2014 23:35, Mark Gaiser <markg85 at gmail.com> wrote:
>> I can't get it to work with a rectangle..
>>
>> import QtQuick 2.0
>> import QtGraphicalEffects 1.0
>>
>> Rectangle {
>>     width: 800
>>     height: 600
>>
>>     DropShadow {
>>         horizontalOffset: 3
>>         verticalOffset: 3
>>         radius: 16
>>         samples: 24
>>         color: "#80000000"
>>         width: blackRect.width
>>         height: blackRect.height
>>         anchors.centerIn: parent
>>
>>         Rectangle {
>>             id: blackRect
>>             width: 500
>>             height: 50
>>             color: "black"
>>         }
>>     }
>> }
>
> Works for me. I copied your code exactly; you can see the result in
> the attachment.

I just noticed that as well. On linux it works a lot less stable. Aka,
i have to start the application about 10x before i finally see one
where the shader effects (DropShadow in this case) are applied.

Also note that you might have a "sort of shadow". It is by no means a
shadow. It's just a "copy" of the rectangle in the color set in
DropShadow. The actual shadow effect (smooth blurred grey.. don't
really know how to call it) isn't applied.



More information about the Interest mailing list