I have added a QTabWidget which is checkable. I want to hide all tabs (panes only) when the TabBar is unchecked and vice versa. Is there any way to make only pane invisible and tab bar will not disappear? I add the image reference related to what I want in output:
Initially both tab pane is minimize and when i click on the tab it will maximize:
after clicking pane is maximize and again i click it will minimize and vice versa:
Instead of using QTabWidget. You can use a QTabBar and implement the functionality you desire hiding the corresponding widget.
here is some sample code of a new widget application example within qt creator
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QTabBar>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_tabbar = new QTabBar(this->centralWidget());
m_tabbar->addTab("Hello");
m_tabbar->addTab("World");
m_tabbar->setShape(QTabBar::RoundedWest);
m_tabbar->setGeometry(0,0,this->height(), 200);
connect(m_tabbar, SIGNAL(tabBarClicked(int)), this, SLOT(changedTab(int)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void
MainWindow::changedTab(int idx)
{
m_tabbar->setCurrentIndex(idx);
ui->stackedWidget->setCurrentIndex(idx);
}