本文整理汇总了Python中PyQt4.QtGui.QTabBar.insertTab方法的典型用法代码示例。如果您正苦于以下问题:Python QTabBar.insertTab方法的具体用法?Python QTabBar.insertTab怎么用?Python QTabBar.insertTab使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTabBar
的用法示例。
在下文中一共展示了QTabBar.insertTab方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: E4SideBar
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import insertTab [as 别名]
#.........这里部分代码省略.........
elif self.isMinimized():
self.expand()
elif evt.type() == QEvent.Wheel and not self.__stackedWidget.isHidden():
if evt.delta() > 0:
self.prevTab()
else:
self.nextTab()
return True
return QWidget.eventFilter(self, obj, evt)
def addTab(self, widget, iconOrLabel, label = None):
"""
Public method to add a tab to the sidebar.
@param widget reference to the widget to add (QWidget)
@param iconOrLabel reference to the icon or the labeltext of the tab
(QIcon, string or QString)
@param label the labeltext of the tab (string or QString) (only to be
used, if the second parameter is a QIcon)
"""
if label:
index = self.__tabBar.addTab(iconOrLabel, label)
self.__tabBar.setTabToolTip(index, label)
else:
index = self.__tabBar.addTab(iconOrLabel)
self.__tabBar.setTabToolTip(index, iconOrLabel)
self.__stackedWidget.addWidget(widget)
if self.__orientation in [E4SideBar.North, E4SideBar.South]:
self.__minSize = self.minimumSizeHint().height()
else:
self.__minSize = self.minimumSizeHint().width()
def insertTab(self, index, widget, iconOrLabel, label = None):
"""
Public method to insert a tab into the sidebar.
@param index the index to insert the tab at (integer)
@param widget reference to the widget to insert (QWidget)
@param iconOrLabel reference to the icon or the labeltext of the tab
(QIcon, string or QString)
@param label the labeltext of the tab (string or QString) (only to be
used, if the second parameter is a QIcon)
"""
if label:
index = self.__tabBar.insertTab(index, iconOrLabel, label)
self.__tabBar.setTabToolTip(index, label)
else:
index = self.__tabBar.insertTab(index, iconOrLabel)
self.__tabBar.setTabToolTip(index, iconOrLabel)
self.__stackedWidget.insertWidget(index, widget)
if self.__orientation in [E4SideBar.North, E4SideBar.South]:
self.__minSize = self.minimumSizeHint().height()
else:
self.__minSize = self.minimumSizeHint().width()
def removeTab(self, index):
"""
Public method to remove a tab.
@param index the index of the tab to remove (integer)
"""
self.__stackedWidget.removeWidget(self.__stackedWidget.widget(index))
self.__tabBar.removeTab(index)
if self.__orientation in [E4SideBar.North, E4SideBar.South]:
self.__minSize = self.minimumSizeHint().height()
示例2: SideBar
# 需要导入模块: from PyQt4.QtGui import QTabBar [as 别名]
# 或者: from PyQt4.QtGui.QTabBar import insertTab [as 别名]
#.........这里部分代码省略.........
if obj == self.__tabBar:
if evt.type() == QEvent.MouseButtonPress:
pos = evt.pos()
index = self.__tabBar.count() - 1
while index >= 0:
if self.__tabBar.tabRect( index ).contains( pos ):
break
index -= 1
if index == self.__tabBar.currentIndex():
if self.isMinimized():
self.expand()
else:
self.shrink()
return True
elif self.isMinimized():
if self.isTabEnabled( index ):
self.expand()
return QWidget.eventFilter( self, obj, evt )
def addTab( self, widget, iconOrLabel, label = None ):
""" Add a tab to the sidebar """
if label:
self.__tabBar.addTab( iconOrLabel, label )
else:
self.__tabBar.addTab( iconOrLabel )
self.__stackedWidget.addWidget( widget )
return
def insertTab( self, index, widget, iconOrLabel, label = None ):
""" Insert a tab into the sidebar """
if label:
self.__tabBar.insertTab( index, iconOrLabel, label )
else:
self.__tabBar.insertTab( index, iconOrLabel )
self.__stackedWidget.insertWidget( index, widget )
return
def removeTab( self, index ):
""" Remove a tab """
self.__stackedWidget.removeWidget( self.__stackedWidget.widget( index ) )
self.__tabBar.removeTab( index )
return
def clear( self ):
""" Remove all tabs """
while self.count() > 0:
self.removeTab( 0 )
return
def prevTab( self ):
""" Show the previous tab """
index = self.currentIndex() - 1
if index < 0:
index = self.count() - 1
self.setCurrentIndex( index )
self.currentWidget().setFocus()