Style Sheet Syntax background
I want to have the background only from a QWidget black. The background from the QPushbuttons, QSliders etc. shoud be normal.
I use the Style-Syntax:
QWidget {
background-color:rgb(20, 20, 20);
}
I read in the Qt Assistant (Stylesheet-Syntax) that i must make bevore the QWidget a point:
.QWidget {
background-color:rgb(20, 20, 20);
}
I have now the problam that this didn't work.
Thanks for help.
Re: Style Sheet Syntax background
well it works, but only for QWidgets! No subclass, even not your own if they only inherit QWidget.
maybe you provide a small executable example showing your problem.
Re: Style Sheet Syntax background
I had this code and it didn't work, the background from the QWidget wouldn't be darker:
Code:
QString styleSheet
= ".QWidget { background-color:rgb(%1, %2 ,%3);}";
styleSheet = styleSheet.arg(bgColor.red()).arg(bgColor.green()).arg(bgColor.blue());
setStyleSheet(styleSheet);
Re: Style Sheet Syntax background
Well your are setting the style sheet on what kind of object? I seems that is is a subclass, which, as told, wont work. But you can use ".NAMEOFYOURCLASS" and then it should work.
Re: Style Sheet Syntax background
Yes, it's a own subclass from QWidget. I use:
Code:
QString styleSheet
= ".myOwnClass {background-color:rgb(%1, %2, %3)}";
but it didnt' work. I think it's a problem of the syntax, because
Code:
QString styleSheet
= "QWidget {background-color:rgb(%1, %2, %3)}";
works and
Code:
QString styleSheet
= ".QWidget {background-color:rgb(%1, %2, %3)}";
didn't work.
Re: Style Sheet Syntax background
I solved the problem:
Code:
QString styleSheet
= "QWidget#MyOwnClass {background-color:rgb(%1, %2, %3)}";
Now it works.
But I don't now why the other syntax don't work.
Thanks for your efforts