Quantcast
Channel: Active questions tagged qtquick2 - Stack Overflow
Viewing all articles
Browse latest Browse all 137

How to change the colour of a row in QML TableView in QT6? I couldn't find any information to achieve this on Qt Quick 2

$
0
0
TableView {        id: testTable        rowSpacing: 0        columnSpacing: 8        clip: true        anchors.topMargin: 2        boundsBehavior: Flickable.OvershootBounds        columnWidthProvider: function(column) {            if(column === 0) return 50;            else if(column === 1) return 580;            else return 60;        }        model: tableModel        delegate: Rectangle {            id: cellContainer            implicitWidth: 100            implicitHeight: 42            Text {                anchors.fill: parent                verticalAlignment: Qt.AlignVCenter                horizontalAlignment: column === 1 ? Qt.AlignLeft : Qt.AlignHCenter                font.family: outfitRegular.name                font.pixelSize: 14                text: {                    var col = model.columnNo                    if(col === 0)                        return model.index                    else if(col === 1)                        return model.name                    else                         return model.status                }            }            MouseArea {                id: mouse                anchors.fill: parent                onClicked: {                    console.log(model.index)                }            }        }    }

I tried coloring the delegate in the mouseArea's onClick method, but as expected, it only changes the cell color and not the entire row's color. I'm wondering what I should do to achieve this.I have found older code on stack overflow but none of them works on the newer version of TableView.

I am new to QML and any input regarding this would be helpful.


Viewing all articles
Browse latest Browse all 137

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>