PDA

View Full Version : QSS - Do not override ForegroundRole in QTreeView



CloudCompany
29th November 2016, 10:01
Hello!

I encountered an issue since last week.
I have a QStyleSheet which some default behavior for QTreeView (colors, borders...).
But in some cases, I would like to punctually change the color of the text, in order to highlight bad values for exemple, and I made this changes in ForegroundRole in data() method.
The problem that the ForegroundRole is completely ignored and it is the QSS attribute which is used.

Example:


QTreeView {
color: black;
}



QVariant data()
{
...
case Qt::ForegroundRole:
return QBrush(Qt::Orange);
}

Orange is never applied and I would like to.

Thanks for your future answers!