Qt utilizing qss styled QTableView, QTreeView, QTableWidget

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/u014746838/article/details/89289156
/*tablewidget 样式*/
QTableView,QTableWidget {
    selection-background-color:#44c767;
    background-color:white;     /*整个表格的背景色,这里为白色*/
    border:1px solid #E0DDDC;   /*边框为1像素,灰色*/
    gridline-color:lightgray;   /*这个是表格的格子线的颜色,为亮灰*/
}

/*这里是表格表头样式*/
QHeaderView::section {
    background-color:white;     /*背景色 白色*/
    border:0px solid #E0DDDC;   /*先把边框宽度设为0,即隐藏所有表头边框*/
    border-bottom:1px solid #E0DDDC;/*然后只显示下边框,因为上边框和左右边框是整个Table的边框,都显示会有2px的边框宽度*/
    height:20px;                /*表头高度*/
}
QTableView{
    color: rgb(0, 0, 0);
    border: 1px solid #C07010;          /*边框颜色*/
    gridline-color:#C07010;             /*grid线颜色*/
    background-color: rgb(20, 20, 20);
    alternate-background-color: rgb(200, 200, 200); /*行交替颜色*/
    selection-background-color: rgb(130, 190, 100); /*选中行背景颜色*/
}
 
QTableView::item:!alternate:!selected{
    background-color: rgb(220, 220, 220);    /*交替行的另一颜色*/
}
QToolButton{
   min-width:80px;
   min-height:32px;
}
QToolButton{
color:rgb(255, 255, 255);
min-height:20;
border-style:solid;
border-top-left-radius:2px;
border-top-right-radius:2px;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241), 
                            stop: 0.3 rgb(160,160,160),
                              stop: 1 rgb(140,140,140));
border:1px;
border-radius:5px;padding:2px 4px;/*border-radius控制圆角大小*/
}
QToolButton:hover{  /*鼠标放上后*/
color:rgb(255, 255, 255);
min-height:20;
border-style:solid;
border-top-left-radius:2px;
border-top-right-radius:2px;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241), 
                            stop: 0.3 rgb(160,160,160),
                              stop: 1 rgb(120,120,120));
border:1px;
border-radius:5px;padding:2px 4px;
}
QToolButton:pressed{ /*按下按钮后*/
color:rgb(255, 255, 255);
min-height:20;
border-style:solid;
border-top-left-radius:2px;
border-top-right-radius:2px;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241), 
                            stop: 0.3 rgb(190,190,190),
                              stop: 1 rgb(160,160,160));
border:1px;
border-radius:5px;padding:2px 4px;
}
QToolButton:checked{    /*选中后*/
color:rgb(255, 255, 255);
min-height:20;
border-style:solid;
border-top-left-radius:2px;
border-top-right-radius:2px;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241), 
                            stop: 0.3 rgb(190,190,190),
                              stop: 1 rgb(160,160,160));
border:1px;
border-radius:5px;padding:2px 4px;
}

 

Guess you like

Origin blog.csdn.net/u014746838/article/details/89289156