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

坚强是说给别人听的谎言 提交于 2019-12-13 07:38:59

问题


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


回答1:


Use a selector:

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

More about styelsheets here.



来源:https://stackoverflow.com/questions/21881479/how-to-prevent-a-style-sheet-in-qgroupbox-from-being-applied-to-the-buttons-insi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!