Qt - How to show tabs of tabified dockwidget at the top instead of the bottom

pyqt4, qdockwidget, qt

Solution

You can call

`QMainWindow.setTabPosition (self, Qt.DockWidgetAreas areas, QTabWidget.TabPosition tabPosition)`

(Notice that this applies to the specific dock area, which means you can have different dock areas with various tab configurations.)

with the enumeration: `Qt.DockWidgetAreas` and `QTabWidget.TabPosition`:

#Qt.DockWidgetAreas
Constant                   Value
---------------------      -------
Qt.LeftDockWidgetArea       0x1
Qt.RightDockWidgetArea      0x2
Qt.TopDockWidgetArea        0x4
Qt.BottomDockWidgetArea     0x8
Qt.AllDockWidgetAreas       DockWidgetArea_Mask
Qt.NoDockWidgetArea         0


#QTabWidget.TabPosition
Constant          Value     Description
----------       -------    -----------
QTabWidget.North    0       The tabs are drawn above the pages.
QTabWidget.South    1       The tabs are drawn below the pages.
QTabWidget.West     2       The tabs are drawn to the left of the pages.
QTabWidget.East     3       The tabs are drawn to the right of the pages.

(Reference: http://pyqt.sourceforge.net/Docs/PyQt4/qmainwindow.html#setTabPosition)

And here is the result:

Problem

In Qt, you can tabify dockWidgets. If I do that, the tabs show on the bottom of the dockWidgets, as is shown in the left sketch. This is the behavior I get under Windows 7 with the latest Qt4 and PyQt4. How can I tell Qt to place the tabs on the dockWidgets top as shown in the right sketch? ``` default: tabs on bottom I want: tabs on top +--------------------+ +------+-----+ | dockWidget1 | | tab1 | tab2|-------+ | | | | | tab1 | tab2|-------| | dockWidget1 | +------+-----+ +--------------------+ ```

Original source