Hello,
I've found this code snippet in PyQt eample for drag and drop of images. Can
anyone plz help me out in understanding this code snippet. I am new to this.


child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QtGui.QPixmap(child.pixmap())

        itemData = QtCore.QByteArray()
        dataStream = QtCore.QDataStream(itemData,
QtCore.QIODevice.WriteOnly)
        dataStream << pixmap << QtCore.QPoint(event.pos() - child.pos())

        mimeData = QtCore.QMimeData()
        mimeData.setData('application/x-dnditemdata', itemData)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - child.pos())
        tempPixmap = QtGui.QPixmap(pixmap)
        painter = QtGui.QPainter()
        painter.begin(tempPixmap)
        painter.fillRect(pixmap.rect(), QtGui.QColor(127, 127, 127, 127))
        painter.end()


Also, what does 'x-dnditemdata' mean in the line:
event.mimeData().hasFormat('application/x-dnditemdata')
I'll be really grateful if someone can help me out with this.

Regrards
Anshul
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to