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.
Qt Code:
  1. #ifndef TABBAR_H
  2. #define TABBAR_H
  3.  
  4. #include <QTabBar>
  5. class TabBar : public QTabBar
  6. {
  7. Q_OBJECT
  8. public:
  9. TabBar(QWidget *parent=0) : QTabBar(parent){}
  10. private:
  11. void toggleVisibility()
  12. {
  13. (count() <= 1) ? hide() : show();
  14. }
  15. protected:
  16. void tabInserted(int) { toggleVisibility(); }
  17. void tabRemoved(int) { toggleVisibility(); }
  18. };
  19. #endif
To copy to clipboard, switch view to plain text mode