I was needing a QLabel that could deal with a mouse hover event – since :hover is not supported by QLabel, I had to override a new class from QLabel, responding to enterEvent() and leaveEvent(). So far so good.
What I really needed was to put an underline decoration on the QLabel text:
QFont f(font());
f.setUnderline(true [or false]);
this->setFont(f);
However, wanting to venture deeper into decoration (changing text color, for example), I was met by a road block. The easiest way to change text color is via stylesheets, but in this case I had other styles applied to the element that I did not want to change, so simply setting a new stylesheet would clear the one already set. I could of course append/delete the parts I wished to change, but it seems to me that’s sort of overcomplicating matters.
To the point: Is it in any way possible to change individual stylesheet styles dynamically for a widget? Like,
QWidget::setStyle("color", "#CCCCCC");
(I know that setStyle is already available, setting a QStyle, but that’s beside the point).
↧