PDA

View Full Version : Change the selection color of a QTableWidget but only for some cells



gab74
6th September 2013, 16:07
Good morning,
i've a table Qtablewidget.

when i click a row it is selected with a colour.

I need that if some cells of the row have a defined background color, this background color must remain and no overridden by the selection color.

So the row selected will be with the selection color, but some cells will remain with their original background color.

Is there any example ?

Thanks to all

TheRonin
18th October 2013, 10:21
I've done something similar to this. I implemented a custom QItemViewDelegate with an overridden paint(QPainter*, const QStyleOptionViewItem& opt, const QModelIndex&)-method. In my method i call the base-class's paint-method with a modified QStyleOptionViewItem where i've set the palette's QPalette::Highlight-role to my custom selection color.