Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTableView custom styling
napajejenunedk0 last edited by napajejenunedk0
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
QBrushes 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
QStyledItemDelegateand customize the
QStyleOptionViewIteminstance in the
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.