转载请注明出处:http://www.cnblogs.com/dachen408/p/7591409.html
选中设置:
QTableView::item:selected
{
background:rgb(0,0,100);
color:white;
}
表头设置:
QHeaderView::section:first
{
border-image: url(:/images/expand/tempUser_headBg2.png);
height: 30px;
font: 11pt "微软雅黑";
}
QHeaderView::section:middle
{
border-image: url(:/images/expand/tempUser_headBg2.png);
height: 30px;
font: 11pt "微软雅黑";
}
QHeaderView::section:last
{
border-image: url(:/images/expand/tempUser_headBg4.png);
height: 30px;
font: 11pt "微软雅黑";
}
滚动条设置:
QScrollBar:vertical {
border: 0px;
background:rgba(255,255,255,0);
border-image:url(:/images/scrollbar/vertical_scrollBg.png);
width: 22px;
margin: 22px 0 22px 0;
}
QScrollBar::handle:vertical {
border-image:url(:/images/scrollbar/vertical_slide.png);
width:22px;
min-height:50px;
max-height:200px;
}
QScrollBar::handle:vertical:hover {
border-image: url(:/images/scrollbar/vertical_slide_hover.png);
width:22px;
min-height:50px;
max-height:200px;
}
QScrollBar::handle:horizontal:hover {
border-image: url(:/images/scrollbar/slide.png);
width:22px;
min-height:35px;
}
QScrollBar::handle:vertical:hover {
border-image:url(:/images/scrollbar/vertical_slide_hover.png);
width:22px;
}
QScrollBar::add-line:vertical {
border-image:url(:/images/scrollbar/vertical_down.png);
height: 22px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::add-line:vertical:pressed{
border-image:url(:/images/scrollbar/vertical_down_down.png);
height: 22px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
border-image:url(:/images/scrollbar/vertical_up.png);
height:22px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical:pressed {
border-image:url(:/images/scrollbar/vertical_up_down.png);
height: 22px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
QScrollBar:horizontal {
border: 0px;
background:rgba(255,255,255,0);
border-image:url(:/images/scrollbar/scrollBg.png);
height: 22px;
margin: 0 22px 0 22px;
}
QScrollBar::handle:horizontal {
border-image:url(:/images/scrollbar/slide.png);
height:22px;
}
QScrollBar::handle:vertical:hover {
border-image:url(:/images/scrollbar/vertical_slide_hover.png);
width:22px;
}
QScrollBar::add-line:horizontal {
border-image:url(:/images/scrollbar/down.png);
width: 22px;
subcontrol-position: right;
subcontrol-origin: margin;
}
QScrollBar::add-line:horizontal:pressed{
border-image:url(:/images/scrollbar/down_down.png);
width: 22px;
subcontrol-position: right;
subcontrol-origin: margin;
}
QScrollBar::sub-line:horizontal {
border-image:url(:/images/scrollbar/up.png);
width:22px;
subcontrol-position: left;
subcontrol-origin: margin;
}
QScrollBar::sub-line:horizontal:pressed {
border-image:url(:/images/scrollbar/up_down.png);
width: 22px;
subcontrol-position: left;
subcontrol-origin: margin;
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
background: none;
}
行之间颜色渐变(alternaingRowColors必须设置为true):
QTableView
{
background-color: rgb(255, 255, 255);
alternate-background-color:#F2F8FF;
}
设置QTreeWidget水平滚动条:
ui.treeWidget_site->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui.treeWidget_site->header()->setStretchLastSection(false);