Hi,

Is there any way to change the style of QTabWidgets of tabbed QDockWidgets by using a stylesheet?

I tried the following snippet from an official example. I expected the tabs to appear centered, but they remained on the left side. The tabs changed their appearance, so the QTabBar properties are applied - but it seems I can't change the QTabWidget.

Note: I show the tabs above the widgets (setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North), but that should not make any difference.

thanks in advance...
Felix

Qt Code:
  1. QTabWidget::pane { /* The tab widget frame */
  2. border-top: 2px solid #C2C7CB;
  3. position: absolute;
  4. top: -0.5em;
  5. }
  6.  
  7. QTabWidget::tab-bar {
  8. alignment: center;
  9. }
  10.  
  11. /* Style the tab using the tab sub-control. Note that
  12.   it reads QTabBar _not_ QTabWidget */
  13. QTabBar::tab {
  14. background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  15. stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
  16. stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
  17. border: 2px solid #C4C4C3;
  18. border-bottom-color: #C2C7CB; /* same as the pane color */
  19. border-top-left-radius: 4px;
  20. border-top-right-radius: 4px;
  21. min-width: 8ex;
  22. padding: 2px;
  23. }
  24.  
  25. QTabBar::tab:selected, QTabBar::tab:hover {
  26. background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  27. stop: 0 #fafafa, stop: 0.4 #f4f4f4,
  28. stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
  29. }
  30.  
  31. QTabBar::tab:selected {
  32. border-color: #9B9B9B;
  33. border-bottom-color: #C2C7CB; /* same as pane color */
  34. }
To copy to clipboard, switch view to plain text mode