Style Sheet Syntax : Selector
저장소/Qt".QWidget {" "background-color: rgba(0, 0, 0, 100%); }"
"QWidget {" "background-color: rgba(0, 0, 0, 100%); }"
결론은 나만 적용할 것인가, 하위 위젯에도 동일하게 적용할 것인가의 차이.
- Q: Style Sheet Syntax background
I want to have the background only from a QWidget black. The background from the QPushbuttons, QSliders etc. shoud be normal.
I use the Style-Syntax:
QWidget {
background-color:rgb(20, 20, 20);
}
I read in the Qt Assistant (Stylesheet-Syntax) that i must make bevore the QWidget a point:
.QWidget {
background-color:rgb(20, 20, 20);
}
I have now the problam that this didn't work.
Thanks for help.
A:
well it works, but only for QWidgets! No subclass, even not your own if they only inherit QWidget.
maybe you provide a small executable example showing your problem.
The Style Sheet Syntax
http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html
Selector Types
All the examples so far used the simplest type of selector, the Type Selector. Qt Style Sheets support all the selectors defined in CSS2. The table below summarizes the most useful types of selectors.
Selector | Example | Explanation |
---|---|---|
Universal Selector | * | Matches all widgets. |
Type Selector | QPushButton | Matches instances of QPushButton and of its subclasses. |
Property Selector | QPushButton[flat="false"] | Matches instances of QPushButton that are not flat. You may use this selector to test for any Qt property that supports QVariant::toString() (see the toString()function documentation for details). In addition, the special class property is supported, for the name of the class. This selector may also be used to test dynamic properties. For more information on customization using dynamic properties, refer toCustomizing Using Dynamic Properties. Instead of =, you can also use ~= to test whether a Qt property of typeQStringList contains a given QString. Warning: If the value of the Qt property changes after the style sheet has been set, it might be necessary to force a style sheet recomputation. One way to achieve this is to unset the style sheet and set it again. |
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. |
Descendant Selector | QDialog QPushButton | Matches all instances of QPushButton that are descendants (children, grandchildren, etc.) of a QDialog. |
Child Selector | QDialog > QPushButton | Matches all instances of QPushButton that are direct children of a QDialog. |
'저장소 > Qt' 카테고리의 다른 글
Qt 5.x GUI 프로젝트 opengl 관련 빌드 오류 (0) | 2014.03.18 |
---|---|
Qt Style Sheets (Qt 5.1) (0) | 2013.11.22 |
Drop Shadow Effect (0) | 2013.11.19 |
QImage, QPixmap의 loadFromData, bitmap image header, resource dll (0) | 2013.10.30 |
widget 프레임 제거와 배경 투명화 (0) | 2013.10.30 |