目的是在矩形的顶部和左侧有较暗的阴影,在同一矩形的底部和右侧有较浅的阴影。这是我尝试过的:import QtQuick 2.12import QtGraphicalEffects 1.12Rectangle{ width: 150 height: 150 Rectangle { id: rect color: "#292a38" anchors.centerIn: parent width: 192 height: 42 radius: 6 } DropShadow { anchors.fill: rect horizontalOffset: 5 verticalOffset: 5 radius: 5 samples: 6 color: "#1c1c26" } DropShadow { anchors.fill: rect horizontalOffset: -5 verticalOffset: -5 radius: 5 samples: 6 color: "#343848" } InnerShadow { anchors.fill: rect radius: 8 samples: 16 horizontalOffset: 10 verticalOffset: 10 color: "#1a1b2f" }}其结果如下:如您所见,这并不令人满意。请指导。
1 回答
茅侃侃
TA贡献1842条经验 获得超21个赞
您忘记设置source效果的属性。
DropShadow
{
anchors.fill: rect
horizontalOffset: 5
verticalOffset: 5
radius: 5
samples: 6
color: "#1c1c26"
source: rect // This is needed
}
添加回答
举报
0/150
提交
取消