如何从QML文件设置
gridview
的背景。 Rectangle {
color: "red"
GridView {
delegate: Rectangle {
color: "transparent"
}
}
}
GridView
,只需将Image
元素嵌套在GridView
元素或其子元素中即可。GridView {
width: 800
height: 600
Image: {
source: "some-image.png"
}
}
GridView
的文档有类似且更好的示例 - http://doc.qt.digia.com/4.7-snapshot/qml-gridview.html#example-usage
另外要注意anchors
属性,它可以帮助您将图像定位在父元素中或其他位置。
Image
元素的文档在这里:http://doc.qt.digia.com/latest/qml-image.html