QTabWidget Background Color Doesn't Change
-
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? -
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).
-
what do you mean by "setting the stylesheet"?
-
like this:
@
tabWidget->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 255, 60);"));
@details see "here":http://doc.qt.nokia.com/latest/stylesheet.html
-
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?
-
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