You only have the option to use:
void QTabWidget::removeTab(int index)
You need to store the pointer to the QWidget in the tab so that you can later insert it.
You could e.g. do something like:
class TabWidget : public QTabWidget
{
Q_OBJECT
enum tabwidgets {tabwidget1,tabwidget2,...,number_of_tabwidgets};
QWidget* widgets_[number_of_tabwidgets];
public:
TabWidget(QWidget* parent = 0) : QWidget(parent)
{
for(int i(0); i < number_of_tabwidgets; ++i)
{
switch(i)
{
case tabwidget1:
insertTab(i,widgets_[i] = new TabWidget1,QString::number(i));
....
}
}
}
};
removeTab
and later, to add it back, just use thefindChild
function to pull up the tab (it's still there, managed by the UI object, even after being removed from the tab widget). See comment dated Aug 12, 2011 here: qtcentre.org/threads/… (and it works for me, 6 years later). – Capua