How highlight TableView row when using DelegateChooser
Unsolved
QML and Qt Quick
-
I have a TableView in QML. I am using a DelegateChooser similar to the qps example. I am able to perform onEntered, onExited events on the individual delegates.
I want to do it on the entire row. I have checked the post [Solved]How to highlight a row in TableView written in QML.
However, I am unable to use this in the DelegateChoosercolor: styleData.row===selectedRow ? "yellow" : "white"
My sample code
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import CustomTableModel 1.0 import Qt.labs.qmlmodels 1.0 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") CustomTableModel { id: customModel } TableView { anchors.fill: parent anchors.margins: 20 columnSpacing: 1 rowSpacing: 1 clip: true model: customModel delegate: chooserDelegate } DelegateChooser { id: chooserDelegate role: "type" //color: styleData.row===selectedRow ? "yellow" : "white" // This line says invalid attribute for color (M16) DelegateChoice { roleValue: "number" Rectangle { implicitWidth: 100 implicitHeight: 50 Text { text: model.number } } } DelegateChoice { roleValue: "text" Rectangle { implicitWidth: 100 implicitHeight: 50 Text { text: model.display } //This works but the highlight is restricted to the cell MouseArea { anchors.fill: parent onEntered: parent.color = "yellow" onExited: parent.color = "red" onClicked: console.log(model.type) } } } //default delegate DelegateChoice { Rectangle { implicitWidth: 100 implicitHeight: 50 Text { text: model.display } } } } }
How can I highlight the row in this case? Thanks