[SOLVED] Hide and show a QTabWidget tab
-
Yes, I tried already. But did not work.
-
I'm not sure if was it's clear, but I want to hide and show a specific tab, not the whole tabBar.
-
Are you talking about something like this
@
void Widget::on_pushButton_clicked()
{
if (m_hiddenWidget) {
ui->tabWidget->insertTab(m_hiddenIndex, m_hiddenWidget, m_hiddenLabel);
m_hiddenWidget = nullptr;
ui->pushButton->setText("Hide");
} else {
m_hiddenWidget = ui->tabWidget->currentWidget();
m_hiddenIndex = ui->tabWidget->indexOf(m_hiddenWidget);
m_hiddenLabel = ui->tabWidget->tabText(m_hiddenIndex);
ui->tabWidget->removeTab(m_hiddenIndex);
ui->pushButton->setText("Show");
}
}
@ -
Thank you for the response, but, I think it won't work in my case because into the tab I have a set of widgets which must to be hidden/showed too.
These tabs were designed using QtCreator and not initialized along with my code, then I do not insert a new tab from my code as it was created before, I thought it would be a matter of setting it as hidden or visible, but it is not looking like so simple.
-
In my example I created QTabWidget in Qt designer.
Each tab in the QTabWidget is a QWidget that contains other widgets.
In my example m_hiddenWidget is a QWidget and it keeps all widgets that are in the current widget like edit lines and the labels.
At the begging m_hiddenWidget is nullptr I use it to keep the content of a hidden tab between remove and insert. -
Ok, I'll try this. When finish it I'll tell you the status.
Thanks again.
-
Thank you so much! It worked.