为一堆选项卡化的 QDockWidget 设置顶部 QDockWidget
在那里。
有人可以告诉我如何设置一个选项卡式 QDockWidget 以弹出到前面(作为活动底座)吗?
在下图中,“完整”选项卡被选中,其内容可见,但我想将“嘴”选项卡设置为所选选项卡并使其内容可见。
代码:
self.dockList = []
approvedAdded = False
# add new dock widgets
for dockName in previewDict.keys():
previewList = previewDict[ dockName ]
# setup dock
dock = QDockWidget( dockName )
dock.setWidget( PreviewWidget( previewList ) )
dock.setAllowedAreas( Qt.TopDockWidgetArea )
dock.setFeatures( QDockWidget.DockWidgetMovable | QDockWidget.DockWidgetFloatable )
# add to ui
self.addDockWidget( Qt.TopDockWidgetArea , dock )
# add to list
insertIndex = len( self.dockList ) - 1
if dockName == "approved":
insertIndex = 0
approvedAdded = True
elif dockName == tfPaths.user():
if not approvedAdded:
insertIndex = 0
else:
insertIndex = 1
self.dockList.insert( insertIndex , dock )
# tabify dock widgets
if len( self.dockList ) > 1:
for index in range( 0 , len(self.dockList) - 1 ):
self.tabifyDockWidget( self.dockList[index] , self.dockList[index + 1] )
# set tab at pos [0] in list to active
if self.dockList:
print self.dockList[0].windowTitle()
self.dockList[0].raise_()
H there.
Can someone please tell me how to set a tabbified QDockWidget to pop to the front (be the active dock)?
In the picture below, the "full" tab is selected and it's contents are visible but I want to set the "mouth" tab to the selected tab and have its contents visible.
Code:
self.dockList = []
approvedAdded = False
# add new dock widgets
for dockName in previewDict.keys():
previewList = previewDict[ dockName ]
# setup dock
dock = QDockWidget( dockName )
dock.setWidget( PreviewWidget( previewList ) )
dock.setAllowedAreas( Qt.TopDockWidgetArea )
dock.setFeatures( QDockWidget.DockWidgetMovable | QDockWidget.DockWidgetFloatable )
# add to ui
self.addDockWidget( Qt.TopDockWidgetArea , dock )
# add to list
insertIndex = len( self.dockList ) - 1
if dockName == "approved":
insertIndex = 0
approvedAdded = True
elif dockName == tfPaths.user():
if not approvedAdded:
insertIndex = 0
else:
insertIndex = 1
self.dockList.insert( insertIndex , dock )
# tabify dock widgets
if len( self.dockList ) > 1:
for index in range( 0 , len(self.dockList) - 1 ):
self.tabifyDockWidget( self.dockList[index] , self.dockList[index + 1] )
# set tab at pos [0] in list to active
if self.dockList:
print self.dockList[0].windowTitle()
self.dockList[0].raise_()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以将选项卡式停靠小部件设置为所选选项卡,如下所示:
编辑
这是一个基于问题中的代码的可运行示例:
A tabified dockwidget can be set as the selected tab like this:
EDIT
Here's a runnable example based on the code in the question: