我想要一个使用Quick的半透明矩形形状,但只有一侧的圆角。
这是我想要的矩形的形状。如果它看不透,我可能只会重叠两个矩形,一个圆角和一个没有。然而,由于重叠变得更深,这在透明度上不起作用。
----------|
/ |
/ |
| |
| |
| |
\ |
\ |
----------|有人有什么想法吗?
发布于 2016-11-01 08:46:06
import QtQuick 2.5
import QtQuick.Window 2.2
Window {
width: 300
height: 300
visible: true
Item {
width: 100
height: 100
anchors.centerIn: parent
clip: true
Rectangle {
anchors.fill: parent
anchors.rightMargin: -radius
radius: 10
color: "navajowhite"
opacity: 0.5
}
}
}您还可以使用层来避免重叠的透明度问题:
import QtQuick 2.5
import QtQuick.Window 2.2
Window {
width: 300
height: 300
visible: true
Item {
width: 100
height: 100
opacity: 0.5
layer.enabled: true
anchors.centerIn: parent
Rectangle {
color: "navajowhite"
radius: 10
anchors.fill: parent
}
Rectangle {
color: "navajowhite"
anchors.fill: parent
anchors.leftMargin: 10
}
}
}https://stackoverflow.com/questions/40354302
复制相似问题