show Tabbar only if there are more than 1 tabs.
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.
Code:
#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
Re: show Tabbar only if there are more than 1 tabs.
Subclass QTabWidget (not QTabBar) and show() or hide() the tabBar() from within tabInserted() or tabRemoved().
Re: show Tabbar only if there are more than 1 tabs.
Thanks. Works fine and there is one less class to clutter my code.