您可以使用剪裁(请参阅性能文档)来切掉单个圆角矩形的角:
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
}
}
}
正如@folibis 所提到的,您也可以使用Canvas,已经有一个类似的答案。