PDA

View Full Version : CSS does not work with custom model + TreeView



dsedov
11th December 2009, 14:29
I am having a great problem here. I have a custom stylesheet set for the MainWindow. I also have two widgets ( QTreeWidget and QTreeView with custom model)
QTreeWidget displays all the stylesheet correctly, now the QTreeView displays background color right (as set in the stylesheet), but when item is selected it shows ugly blue default color, more then that, when QTreeView is not active, selected item has background color and ext color inverted.

In my custom data() call inside my custom model, I do check for foreground color (text) and change it, but for I never check for BackgroundRole so an empty QVariant gets returned.
I tried returning a QColor on BackgroundRole request, and items do change their background color, but selected item is still blue.

How do can I have the background color work the same way as QTreeWidget? I don't want to use an ItemDelegat's paint method, as it is StyleSheet unfriendly and always ends up working slower, then default method.