【发布时间】:2018-04-03 08:09:40
【问题描述】:
我正在尝试让我的水平矩形投下阴影。当我使用下面的代码执行此操作时,矩形重复,因此两行中有两个水平矩形。它显示在图像中(重复的一个是白色的)。如何去掉重复的矩形,只保留阴影和原始矩形?
Window {
visible: true
width: 640
height: 480
color: "white"
Item {
anchors.fill: parent
ColumnLayout {
id: layout
anchors.fill: parent
spacing: 0
Rectangle {
id: bar
color: "blue"
height: 40
Layout.fillWidth: true
}
DropShadow {
anchors.fill: bar
horizontalOffset: 0
verticalOffset: 3
radius: 8.0
samples: 12
source: bar
color: "blue"
}
Rectangle {
Layout.fillHeight: true
Layout.preferredWidth: parent.width
color: "grey"
}
}
}
}
【问题讨论】:
-
我得到以下信息:imgur.com/a/IAoXy,我没有发现问题,在这些情况下,您需要提供minimal reproducible example
-
@eyllanesc 你没有白色背景吗?复制的矩形是白色的,虽然我的例子中的原始矩形是蓝色的,背景是灰色的。
-
可能之前的图片不够充分,但这张图片更具描述性:imgur.com/a/SmY1i
-
是的,我明白了,然后我会尝试在问题中的代码中添加更多内容。
-
测试显示的代码是否重现了您的错误。