5

在 Qt 中,您可以标记 dockWidgets。如果我这样做,选项卡将显示在dockWidgets 的底部,如左草图所示。这是我在使用最新 Qt4 和 PyQt4 的 Windows 7 下得到的行为。我如何告诉 Qt 将选项卡放在dockWidgets 顶部,如右草图所示?

default: tabs on bottom                 I want: tabs on top
+--------------------+                  +------+-----+
| dockWidget1        |                  | tab1 | tab2|-------+
|                    |                  |                    |
| tab1 | tab2|-------|                  | dockWidget1        |
+------+-----+                          +--------------------+
4

1 回答 1

12

你可以打电话

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

(请注意,这适用于特定的停靠区域,这意味着您可以拥有具有不同选项卡配置的不同停靠区域。)

使用枚举:Qt.DockWidgetAreasQTabWidget.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.

(参考: http: //pyqt.sourceforge.net/Docs/PyQt4/qmainwindow.html#setTabPosition

结果如下:

在此处输入图像描述

于 2014-05-20T05:35:48.473 回答