[SOLVED] Change background of QMainWindow without affecting anything else?



  • I only want to affect the background of QMainWindow.

    !http://i.imgur.com/X6vUy0y.png(QMainWindow change background)!

    I tried using:
    @QMainWindow
    {
    background: #5f5;
    }@

    ...but it strangely only affects the corner around the DockWidget (cyan).

    I can use something like:
    @QWidget
    {
    background: #6af;
    }@

    ...but then everything turns "blue". Even he corner of the status bar.

    Any ideas?

    The full Style Sheet i've used is the following:

    @QWidget
    {
    background: #6af;
    }

    QMainWindow
    {
    background: #5f5;
    }

    QStatusBar
    {
    background: #eee;
    }

    QDockWidget
    {
    background: #eee;
    }@

    What I would like to achieve is somthing more similar to this fabricated image.
    !http://i.imgur.com/Jad3UiE.png(QMainWindow background color)!
    (fabricated using mspaint)


  • Moderators

    How about
    @
    #centralWidget {
    background-color: #6AF;
    }
    @
    or whatever you changed the default name to.



  • I like to always use the object name in the stylesheet for what ever object I am trying to target.

    So if your QWidget is named "label_something", then and example style sheet would be

    @
    #label_something {
    ...
    ...
    }
    @

    Edit: Sorry I didn't see the post above earlier. Chris Kawa's message is more direct!



  • I works great! Thanks a bunch! :)

    I actually tried that before, but I thought it didn't work because some bug or limitation inside QDesigner makes it look lite it does not have any effect. You need to acctually "Run" the program to verify that it actually works, so it can be a bit tricky.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.