自定義處理如下:
1、tab組件無背景圖,無外框。
2、tab的標簽做處理:更換3個狀態(tài)下的背景圖,按下是綠色,閑置是黃色,鼠標掃過是紅色。按下時,其他狀態(tài)的tab比按下狀態(tài)的tab要矮6px。
不廢話了,上代碼。
//tab組件的整體坐標、寬度,在創(chuàng)建之初new的時候就setGeometry了。
//pane 指整個tab組件 ,border-width 組件的外框?qū)挾龋?border-color 外框顏色, border-style外框風格,比如outset就是凸出立體感,border-radius 外框的圓角像素。而本示例是無外框,無背景圖的。
QTabWidget::pane
{
border-width: 0px;
border-color:white;
border-style:outset;
border-radius: 3px;
background-color: rgb(132, 171, 208);
background: transparent;
}?
QTabWidget::tab-bar
{
left:0px; //move to,tab標簽的起始位置,左移
}
QTabBar::tab
{
width: 160px; //tab標簽的寬度 長度 指的是單個標簽
height:46px;
font:20px;
color:white //tab上的字體顏色
}
QTabBar::tab:selected
{
margin-left: 1; //距離left 1px
margin-right: 0;
color: white;
border-image: url(./image/call/1.png);
}
QTabBar::tab:!selected
{
color: white;
margin-left: 1;
margin-right: 0;
border-image: url(./image/call/2.png);
}
QTabBar::tab:hover:!selected
{
color: white;
margin-left: 1;
margin-right: 0;
border-image: url(./image/call/3.png);
}
QTabBar::tab:!selected
{
margin-top: 6px; //距離top 6px 下移
margin-bottom: -6px; //距離bottom 6px 下移如果是正數(shù)則上移
}?
新聞熱點
疑難解答