Hi

I have a class that inherits QStandardItem and I put the elements in a QTreeWidget. The class receive notifications from the outside and I want to change the background color of the item based on what happened.

If I do not use stylesheets it works just fine, like this:

void myClass:nExternalEvent() { setBackground(0, QColor(255,0,0))); }

However as soon as I put a stylesheet on the QTreeWidget this has no effect, the stylesheet seems to override the setBackground call.

So I tried : void myClass:nExternalEvent() { this->setStyleSheet("background-color: red"); }

but this is probably all wrong, it changed the color of some other element on my screen, not sure why.

So anyone have an idea on how I can alter the background color like with setBackgroundColor but still be able to use stylesheet on my QTreeWidget?