PDA

View Full Version : QLabel Stylesheet selector issue.



Enygma
23rd August 2007, 16:34
Hello.

I have this label that, under certain programmable circumstances has set the lineWidth attribute 0, 1 or 2 and... depending on that attribute, a CSS gives it a certain background image.
CSS: ( using color instead of image for example purpouse )


QLabel#resultImage[lineWidth="0"] {
background-image: green;
}

QLabel#resultImage[lineWidth="1"] {
background-color: orange;
}

QLabel#resultImage[lineWidth="2"] {
background-color: red;
}

This doesn't work... the label having the orange background color ALL the time.

I`ve read the documentation that says

Warning: If the value of the Qt property changes after the style sheet has been set, it might be necessary to force a style sheet recomputation. One way to achieve this is to unset the style sheet and set it again.

As the attribute changes depending on some conditions ( once a program-s lifetime) I consider heeding this warning and reloading the stylesheet like so:

qApp->setStyleSheet( qApp->styleSheet() );

According to the documentation this should help but it doesn't.

Any other ideas or info?

:confused:

jpn
24th August 2007, 11:46
Hard to say what, but there must be something mixed up. I wrote a small test and it works just fine for me.

Enygma
24th August 2007, 15:23
I tested your example and it works...

Curious enough... mine worked too first... after that it stopped working all of the sudden.

I must be doing something wrong.

I`ll take a closer look.

Thx for confirming it works. I`ll comeback with news. ;)

Enygma
24th August 2007, 15:52
Yep, rewrote it and it worked like a charm :)

Thx for the support.

:rolleyes: