Qt - How to show tabs of tabified dockwidget at the top instead of the bottom

僤鯓⒐⒋嵵緔 提交于 2019-12-12 09:45:17

问题


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        |
+------+-----+                          +--------------------+

回答1:


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:



来源:https://stackoverflow.com/questions/23751503/qt-how-to-show-tabs-of-tabified-dockwidget-at-the-top-instead-of-the-bottom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!