Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED]: QTableView, highlight a part of a row
I have a QTableView with the selection mode set to "row". I want to highlight only a part of the whole row, actually. Say, from column 2 to the end.
I think I must subclass QTableView and reimplement the paint event. But I don't know how to fill the rectangle of the desired cells. Perhaps is there a more convenient way?
archqt last edited by
you want to Highlight when you select a row only ? else for the QAbstractTableModel the data is done for that (display, color, data...).
Yes, I'm talking when the user select a row (i.e. click on a cell of a row).
Otherwise I would use the Qt::background role in the model.
The final goal is to prevent the highlight color to override the background of the first cell.
I mean, I want the first column maintains its own background even when the row is selected.
I tried removing the Qt::ItemIsSelectable from the first cell. The appearance is exactly as I want, but now the delegate won't open anymore...
You can implement you own QStyledItemDelegate and avoid drawing the selection rectangle.
Done. Thank you.