问题描述
在Qt中,可以将dockWidgets制表.如果这样做,选项卡将显示在dockWidgets的底部,如左图所示.这是我在Windows 7下使用最新的Qt4和PyQt4的行为.我如何告诉Qt将选项卡放置在所示的dockWidgets顶部在正确的草图中?
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 shownin the right sketch?
default: tabs on bottom I want: tabs on top
+--------------------+ +------+-----+
| dockWidget1 | | tab1 | tab2|-------+
| | | |
| tab1 | tab2|-------| | dockWidget1 |
+------+-----+ +--------------------+
推荐答案
您可以致电
QMainWindow.setTabPosition (self, Qt.DockWidgetAreas areas, QTabWidget.TabPosition tabPosition)
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.)
,带有枚举: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-如何在顶部而不是底部显示表格化选项卡的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!