我尝试使用 backgroundVisible: false 但不起作用
自定义图像{ id: 表图像 来源:“qrc:/Images/tabel.svg” 锚点{ 底部:btnClose.top 底部边距:4 右:滑块.左 右边距:10 左:scancardimg.left 左边距:55 顶部:scancardimg.top 顶部边距:116 } }
ListModel {
id: modelCeva
ListElement { nrCrt: "226"; joc: "fifa"; tip: "PS5"; valoare: "600"; data: "2023-04-28"; ora: "17:09:12"; }
}
TableView {
id: tableView
anchors.fill: tableImg
backgroundVisible: false
clip: true
TableViewColumn { role: "nrCrt"; title: "Nr. Crt"; width: 70; }
TableViewColumn { role: "joc"; title: "Joc"; width: 100; }
TableViewColumn { role: "tip"; title: "Tip"; width: 100; }
TableViewColumn { role: "valoare"; title: "Valoare"; width: 100; }
TableViewColumn { role: "data"; title: "Data"; width: 100; }
TableViewColumn { role: "ora"; title: "Ora"; width: 100; }
model: modelCeva
style: TableViewStyle {
headerDelegate: Rectangle {
height: textItem.implicitHeight * 1.2
width: textItem.implicitWidth
color: "#00000000";
Text {
id: textItem
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: styleData.textAlignment
anchors.leftMargin: 12
text: styleData.value
elide: Text.ElideRight
color: "white"
renderType: Text.NativeRendering
}
}
}
}
有什么想法吗?
您需要将 TableView 的 backgroundVisible 设置为 false,将 TableViewStyle 的 alternateBackgroundColor 设置为 “透明”。您可以通过将 horizontalScrollBarPolicy 设置为 Qt.ScrollBarAlwaysOff 来隐藏滚动条。下面的例子:
TableView{
backgroundVisible: false
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
...
style: TableViewStyle{
textColor: "white"
alternateBackgroundColor: "transparent"
}
...
}