Home > OS >  How to set stylesheet for multiple buttons but not all
How to set stylesheet for multiple buttons but not all

Time:10-14

I'm using a .qss file to set stylesheet for QPushButton I want to give some buttons a different style than other buttons... Is there any way to do this? Maybe something like

QPushButton#thisbutton{
...
}

CodePudding user response:

for a normal QButton you can do it like you write above:

QPushButton{ color: blue}

if you can, then extend with inheritance the button and do:

MyNewButtonClass{color: red}

or you can directly with the name of the object directly:

QPushButton#okButton { color: gray }

update:

you can ofcourse set the style of buttons without duplicating the sheet...you just do:

QPushButton#okButton, QPushButton#acceptButton, QPushButton#cancelButton
{
    color: green 
}
  •  Tags:  
  • qt
  • Related