5

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        |
+------+-----+                          +--------------------+
Jesper Freesbug
  • 415
  • 4
  • 11
  • 1
    @hyde The OP was asking the **"tabification"** of the `QDockWidget` rather than QTabWidget. The functionality is not that trivial since it was defined in `QMainWindow`, and your link doesn't answer the question at all. – Tay2510 May 21 '14 at 07:11
  • @Tay2510 Oops, you're right. Finding the right place in docs for [this](http://qt-project.org/doc/qt-4.8/qmainwindow.html#setTabPosition) can indeed take some searching. Well, good thing I didn't downvote myself (and the advice itself was sound, even if baseless for this question)... – hyde May 21 '14 at 07:40

1 Answers1

12

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:

enter image description here

Tay2510
  • 5,748
  • 7
  • 39
  • 58