如何防止qgroupbox中的样式表应用于里面的按钮? [英] How to prevent a style sheet in qgroupbox from being applied to the buttons inside?

查看:30
本文介绍了如何防止qgroupbox中的样式表应用于里面的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Qt 编写应用程序.制作一个干净的程序,只添加了一个分组框和两个按钮.

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)");

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.

感谢您的帮助

推荐答案

使用选择器:

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

有关样式表的更多信息此处.

More about styelsheets here.

这篇关于如何防止qgroupbox中的样式表应用于里面的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆