How to prevent a style sheet in qgroupbox from being applied to the buttons inside?

StackOverflow https://stackoverflow.com/questions/21881479

  •  13-10-2022
  •  | 
  •  

Pregunta

I'm writing a application using Qt. Make a clean program and Only added a groupbox and two push buttons.

The only line of code I added is this:

ui->groupBox->setStyleSheet("background-image: url(/home/ariela/test.png)");

The problem is that the background of the push buttons also shows the section the image. I want them to look like normal (default gray) and I can't figure out how to do that.

Thanks for any help

¿Fue útil?

Solución

Use a selector:

ui->groupBox->setStyleSheet("QGroupBox{background-image: url(/home/ariela/test.png);}");

More about styelsheets here.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top