I have a standard QTabWidget, with a corner widget - the only thing special about the QTabWidget is that I use stylesheets to set the tab height.

Is it possible to get the corner widgets to be the same height as the tabs and still display properly within the tabbar area of the tabwidget?

Here is an example of the problem

Qt Code:
  1. #ifndef TABBAR_H
  2. #define TABBAR_H
  3.  
  4. #include "tabbar.h"
  5. #include <QTabWidget>
  6. #include <QToolButton>
  7. #include <QHBoxLayout>
  8. #include <QLabel>
  9.  
  10. #include <QtGui/QMainWindow>
  11.  
  12. class tabbar : public QWidget
  13. {
  14. Q_OBJECT
  15.  
  16. public:
  17. tabbar(QWidget *parent = 0, Qt::WFlags flags = 0)
  18. : QWidget(parent, flags)
  19. {
  20. QToolButton* leftCornerWidget = new QToolButton();
  21. leftCornerWidget->setText("expanding corner widget");
  22. leftCornerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
  23.  
  24. QToolButton* rightCornerWidget = new QToolButton();
  25. rightCornerWidget->setText("fixed height corner widget");
  26. rightCornerWidget->setFixedHeight(50);
  27.  
  28. QTabWidget* tabWidget = new QTabWidget(this);
  29. tabWidget->setCornerWidget(leftCornerWidget, Qt::TopLeftCorner);
  30. tabWidget->setCornerWidget(rightCornerWidget, Qt::TopRightCorner);
  31. tabWidget->addTab(new QLabel("How to make a corner widget the same height as the tabs<br>that stays within the bounds of the tabbar?"), QIcon(), "1 tab");
  32. tabWidget->addTab(new QLabel("How to make a corner widget the same height as the tabs<br>that stays within the bounds of the tabbar?"), QIcon(), "2 tab");
  33. tabWidget->setStyleSheet("QTabBar::tab{ height: 50px; }");
  34.  
  35. QHBoxLayout* layout = new QHBoxLayout(this);
  36. layout->addWidget(tabWidget);
  37.  
  38. this->setLayout(layout);
  39.  
  40. resize(300,300);
  41. show();
  42. }
  43. };
  44.  
  45. #endif // TABBAR_H
To copy to clipboard, switch view to plain text mode 

I am not sure if there is any other way I could be doing it, or if it is simply a Qt Bug (note on MAC the buttons align to the top properly so this problem is windows / linux)
ss.png