Results 1 to 3 of 3

Thread: MainWindow Background-Image issues

  1. #1
    Join Date
    Sep 2009
    Location
    Las Vegas, Nevada - USA
    Posts
    12
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default MainWindow Background-Image issues

    I have a MainWindow with a StyleSheet:

    Qt Code:
    1. background-image: url(:/Images/DefaultBackground);
    To copy to clipboard, switch view to plain text mode 

    My issue is all the widgets on the MainWindow are now using this background instead of their own StyleSheet.

    Also the QLabel are no longer transparent because of the background image.

    What am I doing wrong?

  2. #2
    Join Date
    Sep 2009
    Location
    Las Vegas, Nevada - USA
    Posts
    12
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MainWindow Background-Image issues

    Found my answer:

    It appears that when using a stylesheet at the lowest level all widgets inherit that stylesheet also. (If I am wrong please let me know)

    Qt Code:
    1. background-image: url(:/Images/DefaultBackground);
    2. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2009
    Location
    London
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: MainWindow Background-Image issues

    hey, thats true. I guess when you say "lowest level" you mean the top-level layer. The stylesheet follows a cascading principle, so if you apply style to something at top-level it will inherit in most objects which are within that layer. One way to get aroun that is for example apply the styling specific to a object, so for instance if your QMainWindow was callled "Alpha" and you wanted to style the background only to this main window you could say...

    #alpha {
    background-image: url(:/Images/DefaultBackground);
    }

    instead of....

    QMainWindow {
    background-image: url(:/Images/DefaultBackground);
    }

    the benefit of the first example is that if you have various similar widgets, but you only want to style one of those, this will only apply to the one with that object name.

Similar Threads

  1. Adding image in background
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 6
    Last Post: 9th August 2009, 16:39
  2. QCalendarWidget background image
    By khcbabu in forum Newbie
    Replies: 0
    Last Post: 31st March 2009, 12:51
  3. Issues writing a simple image viewer class
    By ultim8 in forum Qt Programming
    Replies: 5
    Last Post: 27th March 2009, 13:50
  4. How to stretch background image used in brush-palette
    By Hookem in forum Qt Programming
    Replies: 5
    Last Post: 24th December 2008, 17:03
  5. Replies: 5
    Last Post: 10th April 2008, 09:52

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.