PDA

View Full Version : Palette? Stylesheet?



mikey33
18th November 2009, 08:37
Hi, currently I have created an application which allow the user the option of changing the color of all the windows that pop up from say red to yellow or green and have set the background color of the windows with stylesheets, I have also used QSettings to save/load these settings.

Example being...

mainWindow->setStyleSheet("QMainWindow#mainWindow { background-color: red }");

I'm now trying to take the colors a step forward by using gradient colors instead but there seems to be a problem. Using gradient colors seems to color each object, if im saying it right, in the entire window if we use the mainWindow in this case. So all buttons for instance will also have their own stylesheets set which I DON'T want because it looks really messed up especially weird since the buttons have pixmap styles set as an image for their background but anyways

Example being...

mainWindow->setStyleSheet("QMainWindow#mainWindow { background-color: qlineargradient(spread: pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(0, 0, 255, 255), stop:1 rgba(0, 170, 0, 255)) }");

The problems is that all I want is for the background to be colored not the stylesheets of the buttons just the background of the window itself so basically if the steps were first color background, then place buttons on top hence the background wont affect the buttons since they were placed on after the color was applied per say but anyways...

I have thus looked into QPalette since it allows you to specify the role such as...

setBackgroundRole(QPalette::Window)

which actually will ONLY color the background and not all objects in the window BUT this will involve changing all of my stylesheet code and stylesheet load/save settings to palettes so I don't know if anyone knows a better idea or MAYBE a way of implementing BackgroundRole with stylesheets so setting a window style doesn't color every singe object in that window, well thanks again! :)