Qt qss

全局设置,font-family后面可以接多种语言,Qt会根据中英文自动匹配
*{
  font-size:12px;
  font-family:"Microsoft YaHei";
  color:#FFFFFF;
}

基本属性:
--背景透明
background:transparent;
--边框
border:none
border:1px solid #ff0000;
--圆角
border-radius:3px;
--边框样式
border-style: outset;
--字体颜色,红色
color:#ff0000
--字体大小14像素
font-size:14px;
--字体样式
font-style:italic;
--控件内文字距离边框的距离
padding:2px; padding-left:10px;(四个方向)
--宽高
width:30px; height:20px;
--控件之间的间距
margin:0px 0px 0px 0px;
--粗体
font-weight:bold;
--最小最大宽度,高度
min-width:6px;
max-width:6px;
min-height:30px;
--QLineEdit选择的文字的颜色
selection-background-color:rgb(1,123,122);
--去掉边框虚线
outline:0px;
--图片
image:url(:/default/arrow_down);
--文本对其
text-align: center;

///////////////////////////////////////////////////////////////
qss中使用方法:
1>根据自定义类名
MyClass {
}

QWidget#MyClass {
}

2>原始控件类名
QPushButton {
}

3>对象属性
m_label->setProperty("qssname", "myLabel");
QLabel[qssname = "myLabel"] {
}

4>对象名
this->setObjectName("myTree");
或者UI中指定
QTreeWidget[objectName = "myTree"]{
}

///////////////////////////////////////////////////

代码中设置
	setStyleSheet("QFrame#frame{border: 1px solid #ff0000;border-right:none; border-top:none; border-bottom:none;}\
				  QLabel#label1, QLabel#label2{color:#00ff00;font-size:12px; }\
				  QTextEdit#teName::focus{background-color:#00ffff; }");
				  
常用控件:
QPushButton,QToolButton{
}
QPushButton::hover,QToolButton::hover{
}
QPushButton::pressed,QToolButton::pressed{
}
QPushButton::disabled,QToolButton::disabled{
}
QPushButton::checked,QToolButton::checked{
}
QPushButton:default,QToolButton:default{
}
QPushButton:default::hover,QToolButton:default::hover{
}
QPushButton:default::pressed,QToolButton:default::pressed{
}
QPushButton:default::disabled,QToolButton:default::disabled{
}
QPushButton:enabled,QToolButton:enabled{
}
QPushButton:!enabled,QToolButton:!enabled{
}
///////////////////////////////////////////////////////////
QLineEdit{
}
QLineEdit::hover{
}
QLineEdit::pressed{
}
QLineEdit::disabled{
}
QLineEdit::focus{
}

////////////////////////////////////////////////////////////////
QComboBox[qssname="blackComboBox"] { 
  border:0px solid gray;
  background-color:transparent;
  color:rgb(255,255,255);
  font:12px;
}

QComboBox[qssname="blackComboBox"]::down-arrow{
	width:0px;
	height:0px;
}

QComboBox[qssname="blackComboBox"]::drop-down:!editable{
	subcontrol-origin: padding;
	subcontrol-position: center right; 
	border:none;
	width:0px;
	height:0px;
}
QComboBox QAbstractItemView {  
  selection-background-color: #ff0000;   
	border:none;
	outline:none;
} 

////////////////////////////////////////////////////////////
QListWidget{
  background: #ff0000;
	color: #ff00ff;
	border-radius:3px;
	outline:0px;
}
QListWidget::item {
	padding-top:4px;
	padding-bottom:4px;
}
QListWidget::item:selected {
}
QListWidget::item:selected:active {
}
QListWidget::item:selected:!active {
}
QListWidget::item:hover {
	show-decoration-selected: 0;
}

///////////////////////////////////////////////////////
QAbstractItemView[objectName="MyCompleter"] {
	background-color:#ff0000;
	border:none;
	outline:0px;
}
QAbstractItemView[objectName="MyCompleter"]::item:selected:active, 
QAbstractItemView[objectName="MyCompleter"]::item:selected {
	background-color:#ff0000;
}
QAbstractItemView[objectName="MyCompleter"]::item:hover {
	background-color:#ff0000;
}

//////////////////////////////////////////////////////////
QComboBox {
}
QComboBox::drop-down {
	border-top-right-radius: 3px;
	border-bottom-right-radius: 3px;
}
QComboBox::down-arrow {
	image: url(:/down);
}
QComboBox::down-arrow:on {
	image: url(:/up);
}
QComboBox::drop-down:!editable{
	subcontrol-origin: padding;
	subcontrol-position: center right; 
}
QComboBox QAbstractItemView {  
  selection-background-color:#ff0000;
}
////////////////////////////////////////////
QListWidget {
}
QListWidget::item {
}
QListWidget::item:selected {
}

//////////////////////////////////////////
QTextEdit {
}
QTextEdit:hover {
}
QTextEdit:focus {
}
QTextEdit:disabled {
}

////////////////////////////////////////////////
QScrollBar:vertical {
    background:transparent;
    width: 9px;
    margin: 0;
}
QScrollBar::handle:vertical {
    min-height: 40px;
    margin: 0px 0px 0px 0px;
    border-radius: 2px;
    border: none;
}
QScrollBar::handle:vertical:hover {
}
QScrollBar::handle:vertical:pressed {
}
QScrollBar::handle:vertical:disabled {
}
QScrollBar::add-line:vertical {
    height: 0px;
    subcontrol-position: bottom;
    subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
    height: 0px;
    subcontrol-position: top;
    subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
    width: 0px;
    height: 0px;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
    background: transparent;
}
QScrollBar:horizontal {
    background:transparent;
    height: 9px;
    margin: 0;
}
QScrollBar::handle:horizontal {
}
QScrollBar::handle:horizontal:hover {
}
QScrollBar::handle:horizontal:pressed {
}
QScrollBar::handle:horizontal:disabled {
}
QScrollBar::add-line:horizontal {
}
QScrollBar::sub-line:horizontal {
}
QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal {
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
}

//////////////////////////////////////////////////////////////////
QMenu {
}
QMenu::item {
}
QMenu::item:selected {
}
QMenu::item:!enabled {
}
QMenu::separator {
	height:2px;
	background:#ff0000;
}

////////////////////////////////////////////////////////////////////
QToolTip{
    color: #ff0000;
    border-style: none;
    background-color: #ffffff;
}

/////////////////////////////////////////////////////////////////
QScrollArea {
	background-color:transparent;
	border:0px;
}
QScrollArea > QWidget > QWidget{
    background: transparent;
    border: 0px solid black;
    margin: 0px 0px 0px 0px;
} 

/////////////////////////////////////////////////////////////////////
QProgressBar {
	border: 0px solid grey;
	border-radius: 0px;
	text-align: center;
	background-color:#ff0000;
}
QProgressBar::chunk {
	background-color:#00ff00;
}

////////////////////////////////////////////////////////////////////////
QTableWidget {
	background-color:transparent;
	border:0px;
	outline:0px;
}
QTableWidget::item {
}
QTableWidget::item:selected:active,
QTableWidget::item:selected {
}
QTableWidget QHeaderView::section {
	background-color: #ff0000;
}
QTableWidget QHeaderView::up-arrow,
QTableWidget QHeaderView::down-arrow{
 width: 20px;
 height:20px;
}
QTableWidget QHeaderView::down-arrow{
     image: url(:/down);
}
QTableWidget QHeaderView::up-arrow{
     image: url(:/up);
	
}

/////////////////////////////////////////////////////////////////////////
QTreeWidget::branch {
	image:none;
}
QTreeWidget{
	show-decoration-selected: 0;
}
QTreeWidget::item{
}
QTreeWidget::item:selected:active,
QTreeWidget::item:selected{
	show-decoration-selected: 0;
}
QTreeWidget::item:disabled{
}
QTreeWidget::item:hover{
	show-decoration-selected: 0;
}


你可能感兴趣的:(Qt qss)