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

关于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 .

 

 

 

http://blog.csdn.net/aladdina/article/details/4800079

posted @ 2018-01-16 21:31  findumars  Views(1061)  Comments(0Edit  收藏  举报