1

I tried to use qt stylesheet to target a specific column.

In HTML CSS you can do something like this

table.players td:nth-child(N) { /* ... */ }

Looking at the docs, I can't find a way to target a specific qTableView column

http://qt-project.org/doc/qt-4.8/stylesheet.html

http://qt-project.org/doc/qt-4.8/stylesheet-reference.html

http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html

I thought in this example I could replace section with a number to target a specific column but I don't think I understand what it is doing

http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtableview

QTableView QTableCornerButton::section {
   background: red;
   border: 2px outset red;
}

If this is not possible with qt style sheet, what's the best way to override the paint method and reusing Qt's code?

user178047
  • 1,264
  • 15
  • 20

1 Answers1

0

One way to achieve this would be to use a QItemDelegate to render each cell. There are a couple of c++ examples you could translate into Python code:

How can I set the line style of a specific cell in a QTableView?

How do I assign a border to a specific QTableWidgetItem or a row in a QTableWidget?

In your case, you could use the model index (either directly, or to look up data from the model) to determine what sort of border to draw for each cell and when to not draw one at all.

Community
  • 1
  • 1
three_pineapples
  • 11,579
  • 5
  • 38
  • 75