您的位置:首页 > 编程语言 > Qt开发

还是Qt 通过stylesheet或者palette设置背景色的问题

2009-11-11 21:56 351 查看
关于Qt,设置一个widget的背景色后,希望子对象不受影响。 很久以前在QtForum上问过一个问题:http://www.qtforum.org/post/94103/setting-background-color-on-widgets-makes-child-widget-wrong-style.html?highlight=#post94103

在stackoverflow上也有类似的问题:http://stackoverflow.com/questions/177778/in-qt-how-do-i-set-the-background-color-of-a-widget-like-combobox-or-double-spin

现在的方法是:

1. 要是设置整个对话框的,就用palette

2. 要是设置某个对象的,就用selector

Class Selector.QPushButton
Matches instances of
QPushButton
, but not of its subclasses.
This is equivalent to
*[class~="QPushButton"]
.

或者

ID

Selector
QPushButton#okButton
Matches all
QPushButton

instances whose
object name

is
okButton
.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐