Results 1 to 4 of 4

Thread: QLabel Stylesheet selector issue.

  1. #1
    Join Date
    Aug 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation QLabel Stylesheet selector issue.

    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 )
    Qt Code:
    1. QLabel#resultImage[lineWidth="0"] {
    2. background-image: green;
    3. }
    4.  
    5. QLabel#resultImage[lineWidth="1"] {
    6. background-color: orange;
    7. }
    8.  
    9. QLabel#resultImage[lineWidth="2"] {
    10. background-color: red;
    11. }
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. qApp->setStyleSheet( qApp->styleSheet() );
    To copy to clipboard, switch view to plain text mode 

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

    Any other ideas or info?


  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLabel Stylesheet selector issue.

    Hard to say what, but there must be something mixed up. I wrote a small test and it works just fine for me.
    Attached Files Attached Files
    J-P Nurmi

  3. #3
    Join Date
    Aug 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11

    Arrow Re: QLabel Stylesheet selector issue.

    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.

  4. #4
    Join Date
    Aug 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QLabel Stylesheet selector issue.

    Yep, rewrote it and it worked like a charm

    Thx for the support.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.