(self, event)
If the mouse moves far enough when the left mouse button is held
            down, start a drag and drop operation.
If the mouse moves far enough when the left mouse button is held
            down, start a drag and drop operation.
If the mouse moves far enough when the left mouse button is held down start a drag and drop operation .
def mouseMoveEvent(self, event):
        """ If the mouse moves far enough when the left mouse button is held
            down, start a drag and drop operation.
        """
        if not event.buttons() & Qt.LeftButton:
            return

        if (event.pos() - self.dragStartPosition).manhattanLength() \
             < QApplication.startDragDistance():
            return

        if not self.hasImage:
            return

        drag = QDrag(self)
        mimeData = QMimeData()

        output = QByteArray()
        outputBuffer = QBuffer(output)
        outputBuffer.open(QIODevice.WriteOnly)
        self.imageLabel.pixmap().toImage().save(outputBuffer, 'PNG')
        outputBuffer.close()
        mimeData.setData('image/png', output)

        drag.setMimeData(mimeData)
        drag.setPixmap(self.imageLabel.pixmap().scaled(64, 64, Qt.KeepAspectRatio))
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                                      drag.pixmap().height()))
        drag.start()
def mouseMoveEvent ( self , event ) : if not event . buttons ( ) & Qt . LeftButton : return if ( event . pos ( ) - self . dragStartPosition ) . manhattanLength ( ) < QApplication . startDragDistance ( ) : return if not self . hasImage : return drag = QDrag ( self ) mimeData = QMimeData ( ) output = QByteArray ( ) outputBuffer = QBuffer ( output ) outputBuffer . open ( QIODevice . WriteOnly ) self . imageLabel . pixmap ( ) . toImage ( ) . save ( outputBuffer , 'PNG' ) outputBuffer . close ( ) mimeData . setData ( 'image/png' , output ) drag . setMimeData ( mimeData ) drag . setPixmap ( self . imageLabel . pixmap ( ) . scaled ( 64 , 64 , Qt . KeepAspectRatio ) ) drag . setHotSpot ( QPoint ( drag . pixmap ( ) . width ( ) / 2 , drag . pixmap ( ) . height ( ) ) ) drag . start ( )