Search code examples
qtstylesheet

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


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


Solution

  • Use a selector:

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

    More about styelsheets here.