Setting TableView Highlight color in Linux

  • I'm using PyQt4/PySide, but this problem occurs in both, so I think it's a Qt problem generally. I have a TableView. When I want to set the background color of highlighted table items in Windows, I can get the TableView's palette and call
    [code]palette.setColor(QPalette.Highlight, QColor(someColor))[/code]

    and that sets the background color of a highlighted item, no problem. However, this does not work in Linux. (Specifically the different versions of Ubuntu that I've tried.) Instead the highlighted color is always an orange color that Ubuntu likes to use. Is there a way to fix this? Setting other types of colors, such as QPalette.Text, works fine, it's a QPalette.Highlight issue only.

  • Update: No success yet, but this works on both Windows and Linux for a test QTableWidget:

    [code]table.setStyleSheet("QTableWidget::item { selection-background-color: red }")[/code]

    But the equivalent QTableView version does not do anything, strangely, so I still don't have an answer. (I'm using QTableView, the QTableWidget was just for testing.)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.