[PyQt] drag and drop issue.
    Jean-Baptiste BUTET 
    ashashiwa at gmail.com
       
    Thu May  1 17:50:33 BST 2008
    
    
  
Hi all :)
I'm programming drag and drop situation where pixmap is dragged from
my pyqt application to openoffice.
I have implement dragevent and mousspressevent, and it seems to work.
But openoffice (xorg ?) don't see it as a droppable object.
a video of issue:
http://ashashiwa.free.fr//images_diverses/out.ogv
my entire code :
svn co svn://svn.tuxfamily.org/svnroot/oppl/pylewis
drag and drop piece of code:
    def dragEnterEvent(self, event):
        print "dragEnterEvent"
        if (event.mimeData().hasFormat("application/x-dnditemdata")):
            if (event.source()==self):
                event.setDropAction(Qt.MoveAction)
                event.accept()
            else:
                event.acceptProposedAction()
        else:
            event.ignore()
    def mousePressEvent(self, event):
        print "pouet"
        child = self.childAt(event.pos())
        child = self.childAt(event.pos())
        if (not child):
            print "no children"
            return
        print "children"
        pixmap = child.pixmap()
        itemData = QByteArray()
        dataStream = QDataStream(itemData, QIODevice.WriteOnly)
        dataStream << pixmap << QPoint(event.pos()-child.pos())
        mimeData = QMimeData()
        mimeData.setData("application/x-dnditemdata", itemData)
        print "dans la square box"
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos()-child.pos())
        tempPixmap = QPixmap(pixmap)
        child.setPixmap(tempPixmap)
        if (drag.start(Qt.CopyAction | Qt.MoveAction) == Qt.MoveAction):
            child.close()
        else:
            child.show()
            child.setPixmap(pixmap)
Could it be a mimetype pb ?
Clear skies,
JB
-- 
http://astrolix.org
association des linuxiens astronomes
    
    
More information about the PyQt
mailing list