QTableView {
/*表格字体颜色*/
color: rgb(170, 85, 255);
/*鼠标选中时的文字颜色*/
selection-color: red;
/*设置交替颜色,需要 设置 table->setAlternatingRowColors(true);*/
alternate-background-color: red;
/*表格表单背景颜色*/
background-color: rgb(255, 255, 0);
/*鼠标选中时的表格表单背景颜色*/
selection-background-color: lightgray;
/*表格中的网格线条的颜色*/
gridline-color: rgb(170, 85, 255);
/*表格最外层的边框的颜色 none为去除边界线*/
border: 1px solid red;
/*表格四个角的弧度*/
border-radius: 5px;
/*表格与边框的间距*/
padding: 10px 10px;
}
QTableView QWidget {
/*QHeaderView中没有控件的地方的样式*/
background: white;
border: 0px;
}
QTableView::Item {
/*单元格的样式,如果QTableView设置了gridline-color,不会进行覆盖*/
border-left: 1px solid orange;
border-top: 1px solid rgb(0, 170, 255);
border-right: 1px solid rgb(85, 85, 127);
border-bottom: 1px solid red;
}
/*表格中复选框的样式*/
QTableView::indicator:unchecked {
background-color: red;
}
QTableView::indicator:checked {
background-color: yellowgreen;
}
/* QHeaderView的样式*/
QHeaderView {
background: red;
border: 0px solid;
}
QHeaderView:horizontal {
height: 100px;
background-color: rgb(0, 0, 255);
}
QHeaderView:vertical {
width: 20px;
background-color: rgb(241, 251, 255);
}
/*这两部分是headerView默认、悬浮和点击的样式*/
QHeaderView::section {
/*表头文本颜色*/
color: red;
/*表头背景色*/
background-color: rgb(241, 251, 255);
/*表头边框线颜色*/
border-left: 3px solid red;
border-right: 3px solid red;
border-top: 2px solid grey;
border-bottom: none;
}
QHeaderView::section:hover {
background-color: rgb(241, 251, 255);
}
QHeaderView::section:checked {
background-color: rgb(241, 251, 255);
}
/*垂直滚动条整体*/
QScrollBar:vertical {
/*滚动条宽度*/
width: 12px;
/*滚动条背景色*/
background: rgb(170, 170, 255);
/*滚动条距离上下边界的距离*/
margin: 0px, 0px, 0px, 0px;
/*上预留位置 留给图片(看图片的高度)或者样式的*/
padding-top: 12px;
/*下预留位置*/
padding-bottom: 12px;
}
/*滚动条中滑块的样式*/
QScrollBar::handle:vertical {
/*宽度跟随QScrollBar的宽度,这个值设置无效*/
width: 12px;
/*背景颜色*/
background: rgb(0, 0, 0, 25%);
/*弧度*/
border-radius: 6px;
/*最小高度*/
min-height: 20;
}
/*鼠标触及滑块样式 类似于悬浮*/
QScrollBar::handle:vertical:hover {
width: 9px;
background: rgb(0, 0, 0, 50%);
border-radius: 4px;
min-height: 20;
}
/*设置下箭头*/
QScrollBar::add-line:vertical {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/3.png);*/
subcontrol-position: bottom;
}
/*设置上箭头*/
QScrollBar::sub-line:vertical {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/1.png);*/
subcontrol-position: top;
}
/*设置下箭头:悬浮状态*/
QScrollBar::add-line:vertical:hover {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/4.png);*/
subcontrol-position: bottom;
}
/*设置上箭头:悬浮状态*/
QScrollBar::sub-line:vertical:hover {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/2.png);*/
subcontrol-position: top;
}
/*当滚动条滚动的时候,上面和下面的背景颜色*/
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: rgb(0, 0, 0, 10%);
border-radius: 4px;
}
/*垂直滚动条整体*/
QScrollBar:horizontal {
/*滚动条高度*/
height: 12px;
/*滚动条背景色*/
background: rgb(170, 170, 255);
/*滚动条距离左右边界的距离*/
margin: 0px, 0px, 0px, 0px;
/*左预留位置 留给图片(看图片的宽度)*/
padding-left: 12px;
/*右预留位置*/
padding-right: 12px;
}
/*滚动条中滑块的样式*/
QScrollBar::handle:horizontal {
/*高度跟随QScrollBar的宽度,这个值设置无效*/
height: 12px;
/*背景颜色*/
background: rgb(0, 0, 0, 25%);
/*弧度*/
border-radius: 6px;
/*最小高度*/
min-width: 20;
}
/*鼠标触及滑块样式 类似于悬浮*/
QScrollBar::handle:horizontal:hover {
height: 9px;
background: rgb(0, 0, 0, 50%);
border-radius: 4px;
min-width: 20;
}
/*设置左箭头*/
QScrollBar::add-line:horizontal {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/3.png);*/
subcontrol-position: left;
}
/*设置右箭头*/
QScrollBar::sub-line:horizontal {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/1.png);*/
subcontrol-position: right;
}
/*设置左箭头:悬浮状态*/
QScrollBar::add-line:horizontal:hover {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/4.png);*/
subcontrol-position: left;
}
/*设置右箭头:悬浮状态*/
QScrollBar::sub-line:horizontal:hover {
height: 12px;
width: 10px;
/* border-image:url(:/selectfile/scroll/2.png);*/
subcontrol-position: right;
}
/*当滚动条滚动的时候,上面和下面的背景颜色*/
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: rgb(0, 0, 0, 10%);
border-radius: 4px;
}
ui->QTableView->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{" //垂直滑块整体
"background:#FFFFFF;" //背景色
"padding-top:20px;" //上预留位置(放置向上箭头)
"padding-bottom:20px;" //下预留位置(放置向下箭头)
"padding-left:3px;" //左预留位置(美观)
"padding-right:3px;" //右预留位置(美观)
"border-left:1px solid #d7d7d7;}"//左分割线
"QScrollBar::handle:vertical{"//滑块样式
"background:#dbdbdb;" //滑块颜色
"border-radius:6px;" //边角圆润
"min-height:80px;}" //滑块最小高度
"QScrollBar::handle:vertical:hover{"//鼠标触及滑块样式
"background:#d0d0d0;}" //滑块颜色
"QScrollBar::add-line:vertical{"//向下箭头样式
"background:url(:/images/resource/images/checkout/down.png) center no-repeat;}"
"QScrollBar::sub-line:vertical{"//向上箭头样式
"background:url(:/images/resource/images/checkout/up.png) center no-repeat;}");
ui->QTableView->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal{"
"background:#FFFFFF;"
"padding-top:3px;"
"padding-bottom:3px;"
"padding-left:20px;"
"padding-right:20px;}"
"QScrollBar::handle:horizontal{"
"background:#dbdbdb;"
"border-radius:6px;"
"min-width:80px;}"
"QScrollBar::handle:horizontal:hover{"
"background:#d0d0d0;}"
"QScrollBar::add-line:horizontal{"
"background:url(:/images/resource/images/checkout/right.png) center no-repeat;}"
"QScrollBar::sub-line:horizontal{"
"background:url(:/images/resource/images/checkout/left.png) center no-repeat;}");