Qt 如何在保留其他默认属性的同时覆盖TableView.rowDelegate的某些属性

Qt 如何在保留其他默认属性的同时覆盖TableView.rowDelegate的某些属性,qt,qml,qtableview,Qt,Qml,Qtableview,我使用rowDelegate实现可变行高,如下所示。但是,它不使用选定/备用行的默认背景色。如何保留所有我不尝试覆盖的默认值 TableView { id: messagesTable TableViewColumn { role: "severity" title: "" width: 20 delegate: Image { anch

我使用
rowDelegate
实现可变行高,如下所示。但是,它不使用选定/备用行的默认背景色。如何保留所有我不尝试覆盖的默认值

TableView {
        id: messagesTable
        TableViewColumn {
            role: "severity"
            title: ""
            width: 20
            delegate: Image {
                anchors.centerIn: parent
                fillMode: Image.Pad
                source: iconSources[styleData.value.toLowerCase()]
            }
        }
        TableViewColumn {
            role: "message"
            title: "Message"
            width: 300
        }
        TableViewColumn {
            role: "source"
            title: "File"
            width: 150
        }
        TableViewColumn {
            role: "startLine"
            title: "Line"
            width: 40
        }
        TableViewColumn {
            role: "startColumn"
            title: "Column"
            width: 50
        }
        rowDelegate: Rectangle {
            width: childrenRect.width
            height: (messagesModel.get(styleData.row).lineCount || 1) * 20
        }
        model: messagesModel
    }
你不能


使用Qt快速控件进行样式设置的一般规则是:一旦覆盖委托,就从头开始。例如,如果样式提供了
DefaultTableViewRowDelegate
类型,您可以构造该类型的实例,然后它就可以工作了,但是由于默认委托是内联编写的,您无法访问它们。

这真是太遗憾了。您知道在哪里可以访问默认颜色吗?我看到一个
QStyledItemDelegate
…行代理没有类似的功能?有,但我不确定这是否会为您提供所需的颜色。桌面样式使用Qt小部件的样式,正如您可能已经注意到的,但是我非常确定如果您想使用它,您必须使用私有API(对于
QPlatformTheme
,等等)。看起来我至少可以从中获得文本选择颜色,默认情况下,它似乎是用于选定表行的颜色。谢谢