本文整理匯總了Python中PyQt4.QtGui.QTabBar.tabRect方法的典型用法代碼示例。如果您正苦於以下問題:Python QTabBar.tabRect方法的具體用法?Python QTabBar.tabRect怎麽用?Python QTabBar.tabRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtGui.QTabBar
的用法示例。
在下文中一共展示了QTabBar.tabRect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: E4SideBar
# 需要導入模塊: from PyQt4.QtGui import QTabBar [as 別名]
# 或者: from PyQt4.QtGui.QTabBar import tabRect [as 別名]
#.........這裏部分代碼省略.........
if self.splitter:
self.splitter.setSizes(self.splitterSizes)
self.__actionMethod = None
def isMinimized(self):
"""
Public method to check the minimized state.
@return flag indicating the minimized state (boolean)
"""
return self.__minimized
def isAutoHiding(self):
"""
Public method to check, if the auto hide function is active.
@return flag indicating the state of auto hiding (boolean)
"""
return self.__autoHide
def eventFilter(self, obj, evt):
"""
Protected method to handle some events for the tabbar.
@param obj reference to the object (QObject)
@param evt reference to the event object (QEvent)
@return flag indicating, if the event was handled (boolean)
"""
if obj == self.__tabBar:
if evt.type() == QEvent.MouseButtonPress:
pos = evt.pos()
for i in range(self.__tabBar.count()):
if self.__tabBar.tabRect(i).contains(pos):
break
if i == self.__tabBar.currentIndex():
if self.isMinimized():
self.expand()
else:
self.shrink()
return True
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)
示例2: SideBar
# 需要導入模塊: from PyQt4.QtGui import QTabBar [as 別名]
# 或者: from PyQt4.QtGui.QTabBar import tabRect [as 別名]
#.........這裏部分代碼省略.........
self.setMinimumHeight( self.__minSize )
self.setMaximumHeight( self.__maxSize )
diff = self.__bigSize.height() - sizes[ selfIndex ]
sizes[ selfIndex ] = self.__bigSize.height()
else:
self.setMinimumWidth( self.__minSize )
self.setMaximumWidth( self.__maxSize )
diff = self.__bigSize.width() - sizes[ selfIndex ]
sizes[ selfIndex ] = self.__bigSize.width()
if selfIndex == 0:
sizes[ 1 ] -= diff
else:
sizes[ selfIndex - 1 ] -= diff
self.splitter.setSizes( sizes )
return
def isMinimized( self ):
""" Provides the minimized state """
return self.__minimized
def eventFilter( self, obj, evt ):
""" Handle click events for the tabbar """
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: