在Qt中,您可以列出dockWidgets。如果我这样做,标签会显示在dockWidgets的底部,如左侧草图所示。这是我在Windows 7下使用最新的Qt4和PyQt4获得的行为。如何告诉Qt将标签放在dockWidgets顶部,如图所示 在右边的草图中?
default: tabs on bottom I want: tabs on top
+--------------------+ +------+-----+
| dockWidget1 | | tab1 | tab2|-------+
| | | |
| tab1 | tab2|-------| | dockWidget1 |
+------+-----+ +--------------------+
答案 0 :(得分:7)
你可以打电话
QMainWindow.setTabPosition (self,
Qt.DockWidgetAreas areas,
QTabWidget.TabPosition tabPosition)
(请注意,这适用于特定的停靠区域,这意味着您可以使用具有各种标签配置的不同停靠区域。)
使用枚举:Qt.DockWidgetAreas
和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.
(参考:http://pyqt.sourceforge.net/Docs/PyQt4/qmainwindow.html#setTabPosition)
结果如下: