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. QTabWidget Background Color Doesn't Change
Qt 6.11 is out! See what's new in the release blog

QTabWidget Background Color Doesn't Change

Scheduled Pinned Locked Moved General and Desktop
7 Posts 1 Posters 12.7k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    retro_code
    wrote on last edited by
    #1

    Hi,
    I can't seem to change the "window" color of the QTabWidget that I'm using in my project. I'm running Qt Creator 2.0.1 (based on Qt 4.7.0). I'm using the form creator which has a main window and contained within the main window I created a QTabWidget. When I change the Window Color Role in the Palette Editor the change displays in the form designer. However when I compile the project it always changes to plain white no matter what color is selected in the Palette Editor. Any ideas?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      retro_code
      wrote on last edited by
      #2

      I forgot to mention: I can change the text colors, highlight colors, etc in the tab widget so it's just the window color that isn't changing. I also created another tab widget as a test and it gave me the same problem (no matter what color is defined in the palette editor it always shows white after compiling).

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        I do it by setting the stylesheet and it works fine.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          retro_code
          wrote on last edited by
          #4

          what do you mean by "setting the stylesheet"?

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            like this:
            @
            tabWidget->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 255, 60);"));
            @

            details see "here":http://doc.qt.nokia.com/latest/stylesheet.html

            1 Reply Last reply
            0
            • R Offline
              R Offline
              retro_code
              wrote on last edited by
              #6

              Thanks for the code snippet chetankjain. That definitely changes the background color. The bad thing is that it also seems to remove all of the inherited properties of the window (for example, button style and combo box style). Is there another code that will just change the color without destroying all of the other inherited properties?

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on last edited by
                #7

                all child widgets of tabwidget will naturally inherit the style of the tabwidget. so you will have to override the style again in the child widgets. You can also use an external .qss file to define custom styles ... examples "here":http://doc.qt.nokia.com/latest/stylesheet-examples.html

                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