Results 1 to 3 of 3

Thread: StyleSheets and children

  1. #1
    Join Date
    Nov 2008
    Posts
    38
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default StyleSheets and children

    I just tried this:
    Qt Code:
    1. void SomeWidget :: enterEvent (QEvent *) {
    2. setStyleSheet ("background-color: red");
    3. }
    4.  
    5. void SomeWidget :: leaveEvent (QEvent *) {
    6. setStyleSheet (QString());
    7. }
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: StyleSheets and children

    what do you want to achieve?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: StyleSheets and children

    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...

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.