后来是自己写个槽函数去替代解决
setStyleSheet("QTabBar::tab {\
height: 45px\
width: 60px\
}\
QTabBar::tab:selected{\
background-color: rgb(51,51,51)\
}\
QTabWidget::pane {\
border: 1px solid #C2C7CB\
background-color: rgb(51, 51, 51)\
}\
}")
connect(this,SIGNAL(currentChanged(int)),this,SLOT(tabSelectChanged(int)))
void AudioTabWidget::tabSelectChanged(int index)
{
switch(index){
case TAB_GRP: /*选中群组tab*/
this->setTabIcon(TAB_GRP,QIcon(":/res/icon/tab_grp_selected.png"))
this->setTabIcon(TAB_USER,QIcon(":/res/icon/tab_user_unselected.png"))
this->setTabIcon(TAB_CAMERA,QIcon(":/res/icon/tab_camera_unselected.png"))
this->setTabIcon(TAB_CLT,QIcon(":/res/icon/tab_collect_unselected.png"))
break
case TAB_USER: /* 选中用户tab */
this->setTabIcon(TAB_GRP,QIcon(":/res/icon/tab_grp_unselected.png"))
this->setTabIcon(TAB_USER,QIcon(":/res/icon/tab_user_selected.png"))
this->setTabIcon(TAB_CAMERA,QIcon(":/res/icon/tab_camera_unselected.png"))
this->setTabIcon(TAB_CLT,QIcon(":/res/icon/tab_collect_unselected.png"))
break
case TAB_CAMERA: /* 选中摄像头tab */
this->setTabIcon(TAB_GRP,QIcon(":/res/icon/tab_grp_unselected.png"))
this->setTabIcon(TAB_USER,QIcon(":/res/icon/tab_user_unselected.png"))
this->setTabIcon(TAB_CAMERA,QIcon(":/res/icon/tab_camera_selected.png"))
this->setTabIcon(TAB_CLT,QIcon(":/res/icon/tab_collect_unselected.png"))
break
case TAB_CLT: /* 选中收藏tab */
this->setTabIcon(TAB_GRP,QIcon(":/res/icon/tab_grp_unselected.png"))
this->setTabIcon(TAB_USER,QIcon(":/res/icon/tab_user_unselected.png"))
this->setTabIcon(TAB_CAMERA,QIcon(":/res/icon/tab_camera_unselected.png"))
this->setTabIcon(TAB_CLT,QIcon(":/res/icon/tab_collect_selected.png"))
break
default:
break
}
}
在设计师样式表里添加 QTabBar::tab{width:200pxheight::40px}还可以改变颜色QTabBar::tab{backgroind:red} //设置背景颜色为红色欢迎分享,转载请注明来源:内存溢出
评论列表(0条)