def mouseMoveEvent(self, mme): if mme.button() == Qt.NoButton and self._drag_start: # for some reason, the left button is being mapped to NoButton drag_distance = mme.pos() - self._drag_start drag_distance = drag_distance.manhattanLength() if drag_distance > QApplication.startDragDistance(): drag = QDrag(self) mime_data = QMimeData() mime_data.setText(self.label_spidername.text()) drag.setMimeData(mime_data) drag.exec_(Qt.CopyAction | Qt.MoveAction) super(SpiderToolButton, self).mouseMoveEvent(mme)
def mouseMoveEvent(self, mme): if mme.button( ) == Qt.NoButton and self._drag_start: # for some reason, the left button is being mapped to NoButton drag_distance = mme.pos() - self._drag_start drag_distance = drag_distance.manhattanLength() if drag_distance > QApplication.startDragDistance(): drag = QDrag(self) mime_data = QMimeData() mime_data.setText(self.label_spidername.text()) drag.setMimeData(mime_data) drag.exec_(Qt.CopyAction | Qt.MoveAction) super(SpiderToolButton, self).mouseMoveEvent(mme)
def mousePressEvent( self, event ): # handle an internal move # start a drag event if event.button() == Qt.LeftButton and self.dragDropRect().contains(event.pos()): # create the pixmap pixmap = QPixmap.grabWidget(self, self.rect()) # create the mimedata mimeData = QMimeData() mimeData.setText('ItemTitle::%s' % (self.title())) # create the drag drag = QDrag(self) drag.setMimeData(mimeData) drag.setPixmap(pixmap) drag.setHotSpot(event.pos()) if not drag.exec_(): self._accordianWidget.emitItemDragFailed(self) event.accept() # determine if the expand/collapse should occur elif event.button() == Qt.LeftButton and self.expandCollapseRect().contains(event.pos()): self._clicked = True event.accept() else: event.ignore()
def startDrag(self, actions): if self._editor.factory.drag_external: idxs = self.selectedIndexes() rows = sorted(list(set([idx.row() for idx in idxs]))) drag_object = [ (ri, self._editor.value[ri]) for ri in rows] md = PyMimeData.coerce(drag_object) self._dragging = self.currentIndex() drag = QDrag(self) drag.setMimeData(md) # drag.setPixmap(pm) # drag.setHotSpot(hspos) drag.exec_(actions) else: super(_myTableView, self).startDrag(actions)