qt - 如何将背景颜色设置为行?
问题描述
我正在尝试为我的应用程序中的 Row 元素提供背景颜色。到目前为止,我用矩形存档了这个,但它弄乱了 MouseArea 中的图像
这是我的代码:-
import QtQuick.Controls 2.4
import QtQuick 2.11
ApplicationWindow {
id:rootAppWin
width:640
height:480
visible: true
StackView {
id: rooAppStack
anchors.bottomMargin: 50
anchors{
fill:parent
}
}
//Bottom Buttons
Row{
Rectangle {
color: "#19d4d4d4"
anchors.fill:parent
}
id:rootNavButtons
anchors{
top: rooAppStack.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
topMargin: 5
}
MouseArea {
id:marootback
width: parent.width/2
height: parent.height
Image {
id: marootbackimg
fillMode: Image.PreserveAspectFit
source: "qrc:/img/sideswipe.svg"
anchors.fill:parent
}
}
MouseArea {
id:maroothome
width: parent.width/2
height: parent.height
Image {
id: maroothomeimg
fillMode: Image.PreserveAspectFit
source: "qrc:/img/tent.svg"
anchors.fill:parent
}
}
}
}
它弄乱了图像:-
没有矩形它很好用,但我不能设置背景颜色。我应该怎么办 ?
解决方案
将行放在矩形中
Rectangle {
color: "#19d4d4d4"
anchors{
top: rooAppStack.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
topMargin: 5
}
Row{
anchors.fill:parent
id:rootNavButtons
MouseArea {
id:marootback
width: parent.width/2
height: parent.height
Image {
id: marootbackimg
fillMode: Image.PreserveAspectFit
source: "qrc:/img/sideswipe.svg"
anchors.fill:parent
}
}
MouseArea {
id:maroothome
width: parent.width/2
height: parent.height
Image {
id: maroothomeimg
fillMode: Image.PreserveAspectFit
source: "qrc:/img/tent.svg"
anchors.fill:parent
}
}
}
}
推荐阅读
- javascript - 使用 Jquery 将 YouTube 链接从手表更改为动态嵌入
- javascript - 如何在 txt 文件中加载 html 内容以进行电子邮件确认,有什么建议吗?
- django - 如何第二次运行 django 服务器我已经成功安装了 django
- css - CSS样式在mac的Safari浏览器中不起作用
- python - 使用 Python 请求读取 HTML 页面失败
- date - 如果客户端国家/地区从服务器国家/地区更改,newDate() 将如何工作
- postgresql - 表中其他列上每个值的自动增量值
- python - Python:使用 zip() 将列表的超级列表解压缩到单独的列表中
- python - aiohttp.client_exceptions.ClientOSError: [WinError 10054] 现有连接被远程主机强行关闭
- postgresql - postgres 查询以计算包含 ' 或 : 或 " 和空格的数据