在 Qt 中,您可以对dockWidgets 进行制表。如果我这样做,选项卡会显示在dockWidgets 的底部,如左图所示。这是我在使用最新的 Qt4 和 PyQt4 的 Windows 7 下得到的行为。我如何告诉 Qt 将选项卡放在dockWidgets 顶部,如图所示
在正确的草图中?
default: tabs on bottom I want: tabs on top
+--------------------+ +------+-----+
| dockWidget1 | | tab1 | tab2|-------+
| | | |
| tab1 | tab2|-------| | dockWidget1 |
+------+-----+ +--------------------+
最佳答案
你可以打电话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)
结果如下:
关于Qt - 如何在顶部而不是底部显示 tabified dockwidget 的选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23751503/