QT之qss教程-QTabWidget

来源:互联网 发布:node 构建项目 编辑:程序博客网 时间:2024/05/16 23:56

1、普通模式,如图


/* 向在移动 */QTabWidget::tab-bar {left:20px;}QTabBar::tab {background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,                               stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);border:2px solid #C4C4C3;border-bottom-color:red;border-top-left-radius:4px;border-top-right-radius:4px;min-width:8px;padding:2px;}/* 标签被选中时或鼠标悬浮时 */QTabBar::tab:selected,QTabBar::tab:hover {background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,                                stop: 0 #fafafa, stop: 0.4 #f4f4f4,                                stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);}/* 标签被选中时 */QTabBar::tab:selected {border-color:#9B9B9B;border-bottom-color:#C2C7CB;}/* 标签未被选中时 */QTabBar::tab:!selected {margin-top:2px;}


2、被选中的标签,外框扩大,如图


QTabWidget::pane {border:4px solid #C3C7CB;}QTabWidget::tab-bar {left:20px;}/* 标签外形设置 */QTabBar::tab {background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,                                stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,                                stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);border:2px solid #C4C4C3;border-bottom-color:#C2C7CB;border-top-left-radius:4px;border-top-right-radius:4px;min-width:50px;padding:2px;}/* 标签被选中时或鼠标悬浮时 */QTabBar::tab:selected,QTabBar::tab:hover {background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,                                stop: 0 #fafafa, stop: 0.4 #f4f4f4,                                stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);}/* 标签被选中时 */QTabBar::tab:selected {border-color:#9B9B9B;border-bottom-color:#C2C7CB;}/* 标签未被选中时 */QTabBar::tab:!selected {margin-top:2px;}/* 标签被选中时,外框向外扩大 */QTabBar::tab:selected {margin-left:-4px;margin-right:-4px;}/* 最左边的标签被选中时,外框不变化 */QTabBar::tab:first:selected {margin-left:0px;}/* 最右边的标签被选中时,外框不变化 */QTabBar::tab:last:selected {margin-right:0;}

3、标签居中,如图


/* 把显示界面向上移动 */QTabWidget::pane {border-top:2px solid #C2C7CB;position:absolute;top:-10px;}/* 标签居中 */QTabWidget::tab-bar {alignment:center;}QTabBar::tab {background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,                                stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,                                stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);border:2px solid #C4C4C3;border-bottom-color:#C2C7CB;border-top-left-radius:4px;border-top-right-radius:4px;min-width:20px;padding:2px;}QTabBar::tab:selected,QTabBar::tab:hover {background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,                                stop: 0 #fafafa, stop: 0.4 #f4f4f4,                                stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);}QTabBar::tab:selected {border-color:#9B9B9B;border-bottom-color:#C2C7CB;}


原创粉丝点击