Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Change background of QMainWindow without affecting anything else?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adelost
    wrote on last edited by
    #1

    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)

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vezprog
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Adelost
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved