我想设计以下按钮布局:
它有一个重新启动按钮图像放在蓝色背景上 . 我想使用QML在Qt中复制相同的内容 . 我正在使用MouseArea Qt Quick对象,我在Stretch填充模式下重叠图像 . 但是,没有选项可以获得鼠标区域的蓝色背景 . 目前它看起来像这样:
相应的代码相同:
MouseArea {
id: restartbutton
x: 669
width: 50
height: 50
opacity: 1
antialiasing: false
hoverEnabled: true
anchors.top: parent.top
anchors.topMargin: 8
z: 1
Image {
id: image2
anchors.fill: parent
source: "restart_icon.png"
}
}
如何在此处设置MouseArea的背景?
1 回答
您可能想要像这样使用
Rectangle
:请查看QML Advanced Tutorial以获取更多信息