def sendEvent(self, type_, arg1, arg2): type_ = type_.lower() if type_ in ('mousedown', 'mouseup', 'mousemove'): eventType = QMouseEvent.Type(QEvent.None) button = Qt.MouseButton(Qt.LeftButton) buttons = Qt.MouseButtons(Qt.LeftButton) if type_ == 'mousedown': eventType = QEvent.MouseButtonPress elif type_ == 'mouseup': eventType = QEvent.MouseButtonRelease elif type_ == 'mousemove': eventType = QEvent.MouseMove button = buttons = Qt.NoButton assert eventType != QEvent.None event = QMouseEvent(eventType, QPoint(arg1, arg2), button, buttons, Qt.NoModifier) QApplication.postEvent(self.m_webPage, event) QApplication.processEvents() return if type_ == 'click': self.sendEvent('mousedown', arg1, arg2) self.sendEvent('mouseup', arg1, arg2)
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)
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)