在tabwedget添加支持关闭按钮的tab页
void TabDialog::addTab(QWidget *widget, const QIcon &icon, const QString &label)
{
int index = _tabWidget->addTab(widget,icon, label);
TabColseBtn* pbtn = new TabColseBtn(widget);
_tabWidget->tabBar()->setTabButton(index, QTabBar::RightSide, pbtn);
connect(pbtn, SIGNAL(clicked(QWidget* )),this, SLOT(colseTab(QWidget *)));
}
void TabDialog::colseTab(QWidget *tabWidget)
{
int idx = _tabWidget->indexOf(tabWidget);
if(idx > -1){
//这里仅仅移除,没有删除
_tabWidget->removeTab(idx);
delete tabWidget;
}
}