[Qt-interest] CSS does not work with custom model + TreeView

cdawson at dock71.com cdawson at dock71.com
Fri Dec 11 16:06:54 CET 2009


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.




More information about the Qt-interest-old mailing list