Since these properties of DropShadow
don't change:
radius: 10
samples: 15
color: "black"
in my usage, I tried to create a Custom Component named Shadow.qml
that sets these:
anchors.fill: target
source: target
two properties. Here it is:
import QtQuick 2.0
import QtGraphicalEffects 1.0
DropShadow{
id: root
/*
property string target
anchors.fill: target
source: target
*/
//property alias target: root.anchors.fill | root.source
/*
property alias fill: root.anchors.fill
property alias source: root.source
*/
radius: 10
samples: 15
color: "black"
}
and in my usage, I can use it like this:
Shadow{
anchors.fill: myTarget
source: myTarget
}
and it works. The problem is I've to write myTarget
in two places (i.e. anchors.fill
and source
) so I want to reduce it to a single line like this Shadow{ target: myTarget }
I've tried with each of those 3 commented out parts of Shadow.qml
and none of those work!
property string target
should beItem
probably? I don't have a running Qt installation here, but You can tryDropShadow { anchors.fill: source; property alias target: source; ... }
– derMRectangle
. Will it work onItem
as well? – user6283344Item
applying a shader to the non-transparent pixel. Documentation is strange, declaring the type ofsource
to bealias
- when I worked with Qt, that was not a type... But that was with Qt 5.9 – derMRectangle/Item
instead to string works, great! – user6283344