QMainWindow Problem
-
In my application there are 3 windows: One Main Window, and two child windows.
I am changing my main windows background color to white using setstylesheet..
so this is also applying the same settings to my child windows, which I dont want..
In one of my child windows there is a listview with scrollbar, they are also becoming white.
so my question is how can I change my two child windows background settings to their default settings.Thanx in advance..
-
@myWindow->setStyleSheet(QString::fromUtf8("background-color: rgb(254, 255, 247);"));@
-
@extension *e = new extension(this);
e->setWindowModality(Qt::WindowModal);
e->show();a = new ampstart(this);
a->setWindowModality(Qt::WindowModal);
a->show();
@above is the way how I created my stylesheet, and the two child windows..
-
You need to use a more specific selector to ensure that only your QMainWindow selects that particular syle.
Something like this stylesheet snippet should do it:
@
QMainWindow {
background-color: rgb(254, 255, 247);
}
@You can set this directly on yoru mainwindow via the ui file. Just right-click on the main window in design mode of creator and select "Change Stylesheet..." and past the above in and hit Apply.
-
[quote author="ZapB" date="1310040148"]You need to use a more specific selector to ensure that only your QMainWindow selects that particular syle.
Something like this stylesheet snippet should do it:
@
QMainWindow {
background-color: rgb(254, 255, 247);
}
@You can set this directly on yoru mainwindow via the ui file. Just right-click on the main window in design mode of creator and select "Change Stylesheet..." and past the above in and hit Apply.[/quote]
The reason why this is needed is that style sheets are also derived / forwarded to shildren. And you set the properties in a generic way.