Skip to main content
Participant
August 4, 2022
Question

Python Qt QTableWidgetItem background color problem

  • August 4, 2022
  • 1 reply
  • 2236 views

Hi, I'm working on a tool that involves a QTableWidget. I'm trying to set the background color of individual cels based on texture assignements. The problem is, no matter what I try, the color stays the default Designer background color. I've tried QTableWidgetItem.setBackgroundColor() and QTableWidgetItem.setBackground (brush) and it doen't change. Setting a stylesheet for the QTableWidget does change the background color, but it changes it for all items and I still cannot set individual item colors.

 

-chad

This topic has been closed for replies.

1 reply

Participant
August 4, 2022

FYI - I don't know why Designer prevents setting background colors for table widget items, but I solved the issue by writing a custom itemDelegate and overriding the paint function.