QT Designer changing the child's stylesheet from the parent's stylesheet
-
Hello,
I applied a fairly simple stylesheet to a widget to this apply a border. The labels in the widget are therefore also affected by the border and I would like to add an instruction to be able to remove it but I don't know how to do it and if we can do it without going through source code :
Thanks
-
@beautifulcloud
My bad, now I understand from your screenshot. I had not seen it was doing anything other than theQLabel
.Not sure quite how you "cancel" or "override". I would try something other than
none
to test if that works.In order to set only the border of this "parent" widget, and not worry about affecting its children, why not try giving it an objectName of
thisWidget
and then:#thisWidget { border: 3px solid #663d24; }
Then you don't need the
QLabel
rule for children. -
@beautifulcloud said in QT Designer changing the child's stylesheet from the parent's stylesheet:
I applied a fairly simple stylesheet to a widget to this apply a border.
Could you show how exactly you did this, what the QSS looks like?
-
Hello @JonB ,
The image above is the CSS of the widget, so the label inside the widget have border too and I would like to remove it
Since I have a lot of labels to add I was wondering if it was possible to remove the border of the label by adding a CSS code to the widget without going through the source code
QLabel { border: none; }
But it doesn't work I guess we are not supposed to do like this
-
@beautifulcloud
No, I want to see the text of whatever QSS/CSS you added to the parent where you sayI applied a fairly simple stylesheet to a widget to this apply a border.
You have shown how you are trying to cancel the children's borders. I would like to see how you set the parent's border?
-
@beautifulcloud
My bad, now I understand from your screenshot. I had not seen it was doing anything other than theQLabel
.Not sure quite how you "cancel" or "override". I would try something other than
none
to test if that works.In order to set only the border of this "parent" widget, and not worry about affecting its children, why not try giving it an objectName of
thisWidget
and then:#thisWidget { border: 3px solid #663d24; }
Then you don't need the
QLabel
rule for children. -