PDA

View Full Version : StyleSheets and children



spraff
26th November 2008, 19:26
I just tried this:


void SomeWidget :: enterEvent (QEvent *) {
setStyleSheet ("background-color: red");
}

void SomeWidget :: leaveEvent (QEvent *) {
setStyleSheet (QString());
}

The widget's background color is not set, its children's background colours are!

How do I prevent the stylesheet from being inherited?

I've been trying to use the backgroundRole property instead -- to no effect. I need a solution in stylesheets for other reasons.

Thanks a lot, the folks on this forum have been a great help so far. :p

spirit
26th November 2008, 19:33
what do you want to achieve?

wysota
26th November 2008, 20:00
I think you might want to set autoFillBackground property to true. But I think what you really want is to use the :hover pseudo-state in the stylesheet (provided your widget is based on a widget that supports it). Or maybe you should just paint the background yourself and forget stylesheets - they are likely not for you...