I have an application which loads a .qss styling file and apply the stylesheet to the whole application. My problem is that it modifies the default QGroupBox
styling instead of a subclass of it, and I would like a default-style QGroupBox
in one place.
Here is an example of the styling applied application wide that I'm trying to replace by the default one.
QGroupBox {
border: 0px solid gray;
border-bottom: 1px solid block;
}
I have tried to reset the stylesheet by using
_ui->setupUi(this);
_ui->myGroupBox->setStylesheet("");
But this does not work. From what I've gathered, the application-wide styling should have happened duing the setupUi()
phase though, and thus be overwritten by the empty (default) stylesheet. This does not seem to be the case.
I have also tried without success to set it directly from Qt Designer, or from the qss file using.
myGroupBox {
}
However, if I put border-bottom: 1px solid red;
in the qss file, it is correctly registered and overrule the default style. I do not now the default parameters though, so I cannot set them all by hand if needed.
If I remove the annoying qss rule, it works fine, but it breaks the application ui in 50 other places and I sadly do not have the time to refactor it right now.
Am I missing something when it comes to resetting to the default stylesheet?
Thanks.
You seem to be mixing up the styles with stylesheets. These are different beasts. When a widget has a stylesheet, it is not styled by the style mechanism anymore, because the styles in general aren't flexible enough to be modified by stylesheets, since they e.g. depend on platform-provided images etc. The two mechanisms are exclusive of each other: either one can control the appearance of the widget, but once you use a stylesheet, it's all-or-nothing: the style mechanism is out of the picture.
Simply fix your stylesheet to apply only to the group boxes it should apply to - you can select them by name or name path.