QTableView custom styling
Unsolved
General and Desktop
-
Hello, all.
The concrete desired behavior is: color selective
QTableView
's rows based on some data provided by the used model e.g. a given role has special value. The possible ways to do it:- Use stylesheet. Here comes the question: how to differentiate which cells are having the desired value for the given role?
- Provide the necessary cosmetic data through the model. The problem is that the data variety that could be provided this way is constrained to the background and foreground
QBrush
es and the text font and alignment. Also, noticed that it is not working 100% of the time and can't tell whether this cosmetic data would be overridden or not by a stylesheet if the latter is used in addition. - Implement 1. by reading the given role's value in a subclassed
QStyledItemDelegate
and customize theQStyleOptionViewItem
instance in theQStyledItemDelegate::paint
member function.
It would be best if 1. is somehow possible. If it is or if there's another more integrated approach aside the delegate one (3.) it would be great. Any suggestions are welcome.