Is there an easy way to display the tabbar only when there are more than 1 tabs? Right now, I've a subclassed QTabBar and redefined tabInserted, tabRemoved to check the numbers of tabs and toggle the visibility of the Tabbar accordingly. Is there a more simple way to do this? Maybe a member function of QTabWidget where I can activate/deactivate this behaviour? I could'nt find anything.
#ifndef TABBAR_H
#define TABBAR_H
#include <QTabBar>
{
Q_OBJECT
public:
private:
void toggleVisibility()
{
(count() <= 1) ? hide() : show();
}
protected:
void tabInserted(int) { toggleVisibility(); }
void tabRemoved(int) { toggleVisibility(); }
};
#endif
#ifndef TABBAR_H
#define TABBAR_H
#include <QTabBar>
class TabBar : public QTabBar
{
Q_OBJECT
public:
TabBar(QWidget *parent=0) : QTabBar(parent){}
private:
void toggleVisibility()
{
(count() <= 1) ? hide() : show();
}
protected:
void tabInserted(int) { toggleVisibility(); }
void tabRemoved(int) { toggleVisibility(); }
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks