I am learning to use the Qt Stylesheet to add different styles to my application. I looked online and saw the Qt Documentation which said that you can use something called ID Selector that can apply the theme to certain objects. This is how I implemented this feature :
QPushButton#button
{
color:red;
}
But it doesn't work. It only works when I try without the ID Selector:
QPushButton
{
color:red;
}
Why doesn't this work ? I used copy and paste, so I'm 100% sure that I didn't got the name wrong.
I found out the answer, and it's actually really simple. I forgot to add button->setObjectName("Name");, which caused the stylesheet to not know about the button. Just add in this line of code and it should work properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With