stepBystep
stepBystep

Reputation: 187

QTableWidget - Change the row color

I'm trying to change the background color of a QTableWidget row. There are some others posts about the same thing but none of the given solutions worked for me.

It's working, but set background for the row with iterating needs more time if you have more then one table. I need a function to change the row background by passing only the row index!

Upvotes: 12

Views: 35186

Answers (1)

eyllanesc
eyllanesc

Reputation: 244301

There is no function that performs this task, but we can create it, for example:

def setColortoRow(table, rowIndex, color):
    for j in range(table.columnCount()):
        table.item(rowIndex, j).setBackground(color)

enter image description here

Upvotes: 29

Related Questions