1、普通模式,如圖
1 /* 向在移動 */
2 QTabWidget::tab-bar { 3 left:20px; 4 } 5
6 QTabBar::tab { 7 background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 8 stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, 9 stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); 10 border:2px solid #C4C4C3; 11 border-bottom-color:red; 12 border-top-left-radius:4px; 13 border-top-right-radius:4px; 14 min-width:8px; 15 padding:2px; 16 } 17
18 /* 標簽被選中時或鼠標懸浮時 */
19 QTabBar::tab:selected,QTabBar::tab:hover { 20 background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 21 stop: 0 #fafafa, stop: 0.4 #f4f4f4, 22 stop: 0.5 #e7e7e7, stop: 1.0 #fafafa); 23 } 24
25 /* 標簽被選中時 */
26 QTabBar::tab:selected { 27 border-color:#9B9B9B; 28 border-bottom-color:#C2C7CB; 29 } 30
31 /* 標簽未被選中時 */
32 QTabBar::tab:!selected { 33 margin-top:2px; 34 }
2、被選中的標簽,外框擴大,如圖
1 QTabWidget::pane { 2 border:4px solid #C3C7CB; 3 } 4
5 QTabWidget::tab-bar { 6 left:20px; 7 } 8
9 /* 標簽外形設置 */
10 QTabBar::tab { 11 background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 12 stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, 13 stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); 14 border:2px solid #C4C4C3; 15 border-bottom-color:#C2C7CB; 16 border-top-left-radius:4px; 17 border-top-right-radius:4px; 18 min-width:50px; 19 padding:2px; 20 } 21
22 /* 標簽被選中時或鼠標懸浮時 */
23 QTabBar::tab:selected,QTabBar::tab:hover { 24 background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 25 stop: 0 #fafafa, stop: 0.4 #f4f4f4, 26 stop: 0.5 #e7e7e7, stop: 1.0 #fafafa); 27 } 28
29 /* 標簽被選中時 */
30 QTabBar::tab:selected { 31 border-color:#9B9B9B; 32 border-bottom-color:#C2C7CB; 33 } 34
35 /* 標簽未被選中時 */
36 QTabBar::tab:!selected { 37 margin-top:2px; 38 } 39
40 /* 標簽被選中時,外框向外擴大 */
41 QTabBar::tab:selected { 42 margin-left:-4px; 43 margin-right:-4px; 44 } 45
46 /* 最左邊的標簽被選中時,外框不變化 */
47 QTabBar::tab:first:selected { 48 margin-left:0px; 49 } 50
51 /* 最右邊的標簽被選中時,外框不變化 */
52 QTabBar::tab:last:selected { 53 margin-right:0; 54 }
3、標簽居中,如圖
1 /* 把顯示界面向上移動 */
2 QTabWidget::pane { 3 border-top:2px solid #C2C7CB; 4 position:absolute; 5 top:-10px; 6 } 7
8 /* 標簽居中 */
9 QTabWidget::tab-bar { 10 alignment:center; 11 } 12
13 QTabBar::tab { 14 background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 15 stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, 16 stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); 17 border:2px solid #C4C4C3; 18 border-bottom-color:#C2C7CB; 19 border-top-left-radius:4px; 20 border-top-right-radius:4px; 21 min-width:20px; 22 padding:2px; 23 } 24
25 QTabBar::tab:selected,QTabBar::tab:hover { 26 background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 27 stop: 0 #fafafa, stop: 0.4 #f4f4f4, 28 stop: 0.5 #e7e7e7, stop: 1.0 #fafafa); 29 } 30
31 QTabBar::tab:selected { 32 border-color:#9B9B9B; 33 border-bottom-color:#C2C7CB; 34 }