QTabWidget的第二个tab怎么设置sheetStyle
展开全部
这个问题我也纠结过 实在是找不到设置第二个tab的方法
后来是自己写个槽函数去替代解决
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;
}
}
后来是自己写个槽函数去替代解决
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;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询