一.隐藏标题栏
ui->tabWidget->tabBar()->hide();//tab->hide()
二.显示隐藏内容栏(QWidget)
ui->tabWidget->addTab(ui->tab,"端口2");//想要重新显示
ui->tabWidget->removeTab(1);//删除该页,实际该页还在
三.隐藏QDockWidget在tabify后的标题栏(QTabBar)
3.1 通用样式表( tab的background、color设为transparent;)
QTabWidget#tabWidgetMenuBar {
background: rgb(243,243,243);
border-top: 0px solid #eee;
border-width:0;
padding:1px 1px;
}
QTabBar::tab {
background: transparent;
height:30px;
padding:2px 12px;
color:transparent;
border-width:0;
width:0;
}
QTabBar::tab:selected {
background: rgb(243,243,243);
color:rgb(43,87,154);
border-color: #9B9B9B;
border-bottom-color: #C2C7CB; /* same as pane color */
}
QTabBar::tab:!selected {
color:gray;
}
3.2 单独样式表
QTabBar::tab {
color:#fff;
width:48;
background: transparent;
height:30px;
padding:2px 12px;
border-width:0;
}
QTabBar::tab:selected {
background: rgb(243,243,243);
color:rgb(43,87,154);
border-color: #9B9B9B;
border-bottom-color: #C2C7CB; /* same as pane color */
}
QTabBar::tab:!selected {
color:gray;
}
四.样式表开源示例
QtExtTabWidget
QPinnableTabWidget
右键标题可去红叉,显示、隐藏。