本文整理汇总了Python中PyQt4.QtGui.QTabBar类的典型用法代码示例。如果您正苦于以下问题:Python QTabBar类的具体用法?Python QTabBar怎么用?Python QTabBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTabBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__( self, parent = None ):
QTabBar.__init__( self, parent )
self.lineEdit = self.FramelessLineEdit( self )
self.currentTab = -1
self.connect( self.lineEdit, SIGNAL( 'returnPressed()' ), self.slotReturnPressed )
示例2: __init__
def __init__(self, parent, ancestor):
QTabBar.__init__(self, parent)
self.ancestor = ancestor
# Dragging tabs
self.__drag_start_pos = QPoint()
self.setAcceptDrops(True)
示例3: __init__
def __init__(self, parent = None):
"""
Constructor
@param parent reference to the parent widget (QWidget)
"""
QTabBar.__init__(self, parent)
self._tabWidget = parent
示例4: dragEnterEvent
def dragEnterEvent(self, event):
"""Override Qt method"""
mimeData = event.mimeData()
formats = mimeData.formats()
if formats.contains("parent-id") and \
mimeData.data("parent-id").toLong()[0] == id(self.ancestor):
event.acceptProposedAction()
QTabBar.dragEnterEvent(self, event)
示例5: __init__
def __init__(self, parent=None, *args, **kwargs):
"""
Reset tab text orientation on initialization
:param width: Remove default width parameter in kwargs
:param height: Remove default height parameter in kwargs
"""
self.tabSize = QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
QTabBar.__init__(self, parent, *args, **kwargs)
示例6: mouseMoveEvent
def mouseMoveEvent(self,event):
index = 0
while(index < self.count()):
if self.tabRect(index).contains(event.pos(),True):
self.hoveredTab = index
self.repaint()
break
index += 1
QTabBar.mouseMoveEvent(self,event)
示例7: __init__
def __init__(self, parent):
" init class custom tab bar "
QTabBar.__init__(self, parent)
self._editor = QLineEdit(self)
self._editor.setToolTip(" Type a Tab Name ")
self._editor.setWindowFlags(Qt.Popup)
self._editor.setFocusProxy(self)
self._editor.editingFinished.connect(self.handleEditingFinished)
self._editor.installEventFilter(self)
示例8: mouseDoubleClickEvent
def mouseDoubleClickEvent( self, event ):
QTabBar.mouseDoubleClickEvent( self, event )
index = self.tabAt( event.pos() )
if index < 0:
self.lineEdit.hide()
return
self.currentTab = index
self.lineEdit.show()
self.lineEdit.setGeometry( self.tabRect( index ) )
self.lineEdit.setText( self.tabText( index ) )
self.lineEdit.setFocus()
self.lineEdit.selectAll()
示例9: dropEvent
def dropEvent(self, event):
"""Override Qt method"""
mimeData = event.mimeData()
index_from = mimeData.data("source-index").toInt()[0]
index_to = self.tabAt(event.pos())
if mimeData.data("tabbar-id").toLong()[0] != id(self):
tabwidget_from = mimeData.data("tabwidget-id").toLong()[0]
self.emit(SIGNAL("move_tab(long,int,int)"),
tabwidget_from, index_from, index_to)
event.acceptProposedAction()
elif index_from != index_to:
self.emit(SIGNAL("move_tab(int,int)"), index_from, index_to)
event.acceptProposedAction()
QTabBar.dropEvent(self, event)
示例10: mouseMoveEvent
def mouseMoveEvent(self, event):
"""Override Qt method"""
if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
(event.pos() - self.__drag_start_pos).manhattanLength() > \
QApplication.startDragDistance():
drag = QDrag(self)
mimeData = QMimeData()
mimeData.setData("parent-id", QByteArray.number(id(self.ancestor)))
mimeData.setData("tabwidget-id",
QByteArray.number(id(self.parentWidget())))
mimeData.setData("tabbar-id", QByteArray.number(id(self)))
mimeData.setData("source-index",
QByteArray.number(self.tabAt(self.__drag_start_pos)))
drag.setMimeData(mimeData)
drag.exec_()
QTabBar.mouseMoveEvent(self, event)
示例11: eventFilter
def eventFilter(self, widget, event):
" filter mouse, esc key, events "
if (event.type() == QEvent.MouseButtonPress and not self._editor.geometry().contains(event.globalPos())) or (
event.type() == QEvent.KeyPress and event.key() == Qt.Key_Escape
):
self._editor.hide()
return True
return QTabBar.eventFilter(self, widget, event)
示例12: addWidgets
def addWidgets(self):
"""Create main layout."""
logger = self.logger
logger.debug('adding widgets')
layout = QVBoxLayout()
self.setLayout(layout)
layout.setSpacing(0)
layout.setContentsMargins(0, 0, 0, 0)
tabbar = QTabBar(self)
tabbar.setFocusPolicy(Qt.NoFocus)
tabbar.setVisible(False)
tabbar.currentChanged.connect(self.changeVault)
layout.addWidget(tabbar)
self.tabbar = tabbar
stack = QStackedWidget(self)
layout.addWidget(stack)
novault = NoVaultWidget(stack)
stack.addWidget(novault)
self.stack = stack
示例13: mouseMoveEvent
def mouseMoveEvent(self, event):
"""Override Qt method"""
if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
(event.pos() - self.__drag_start_pos).manhattanLength() > \
QApplication.startDragDistance():
drag = QDrag(self)
mimeData = QMimeData()
# Converting id's to long to avoid an OverflowError with PySide
ancestor_id = long(id(self.ancestor))
parent_widget_id = long(id(self.parentWidget()))
self_id = long(id(self))
mimeData.setData("parent-id", QByteArray.number(ancestor_id))
mimeData.setData("tabwidget-id",
QByteArray.number(parent_widget_id))
mimeData.setData("tabbar-id", QByteArray.number(self_id))
mimeData.setData("source-index",
QByteArray.number(self.tabAt(self.__drag_start_pos)))
drag.setMimeData(mimeData)
drag.exec_()
QTabBar.mouseMoveEvent(self, event)
示例14: paintEvent
def paintEvent(self,event):
painter = QPainter(self)
if self.hasUnderLine:
rect = self.tabRect(self.hoveredTab)
linesPath = QPainterPath()
linesPath.moveTo(QPoint(rect.x()+10,rect.height()-5))
linesPath.lineTo(QPoint(rect.x()-10+rect.width(),rect.height()-5))
linesPath.closeSubpath()
painter.setPen(QPen(QColor(170,200,200),6))
painter.drawPath(linesPath)
# 如果不是当前选中的页,在页标签下画线
if self.hoveredTab != self.currentIndex ():
if self.isTabEnabled(self.hoveredTab):
rect = self.tabRect(self.hoveredTab)
linesPath = QPainterPath()
linesPath.moveTo(QPoint(rect.x()+10,rect.height()-5))
linesPath.lineTo(QPoint(rect.x()-10+rect.width(),rect.height()-5))
linesPath.closeSubpath()
painter.setPen(QPen(QColor(170,200,200),6))
painter.drawPath(linesPath)
QTabBar.paintEvent(self,event)
示例15: dropEvent
def dropEvent(self, event):
"""Override Qt method"""
mimeData = event.mimeData()
index_from = mimeData.data("source-index").toInt()[0]
index_to = self.tabAt(event.pos())
if index_to == -1:
index_to = self.count()
if mimeData.data("tabbar-id").toLong()[0] != id(self):
tabwidget_from = str(mimeData.data("tabwidget-id").toLong()[0])
# We pass self object ID as a QString, because otherwise it would
# depend on the platform: long for 64bit, int for 32bit. Replacing
# by long all the time is not working on some 32bit platforms
# (see Issue 1094, Issue 1098)
self.emit(SIGNAL("move_tab(QString,int,int)"),
tabwidget_from, index_from, index_to)
event.acceptProposedAction()
elif index_from != index_to:
self.emit(SIGNAL("move_tab(int,int)"), index_from, index_to)
event.acceptProposedAction()
QTabBar.dropEvent(self, event)