PyQt: Pulling Abstract Item Data from Mime Data using Drag and Drop.

Mudcat mnations at gmail.com
Thu Dec 11 20:05:15 EST 2008


I'm trying to drag/drop info from a TreeWidget into a TextBox. I have
been able to modify the TextEdit box to override the dragEnterEvent
like this:

    class TextEdit(QtGui.QTextEdit):
      def __init__(self, title, parent):
        QtGui.QTextEdit.__init__(self, title, parent)
        self.setAcceptDrops(True)

    def dragEnterEvent(self, event):
      if event.mimeData().hasFormat('text/plain'):
        event.accept()
      elif (event.mimeData().hasFormat("application/x-
qabstractitemmodeldatalist")):
        print event
        itemData = event.mimeData().retrieveData("application/x-
qabstractitemmodeldatalist", QtCore.QVariant.List)


The drag is working up until the point I try to actually retrieve the
data. At that point I get an unhandled Runtime Error saying "no access
to protected functions or signals for objects not created in Python".
Obviously I am not retrieving them in the correct format. Does anyone
know how to convert/retrieve the information into a Python list?

Thanks



More information about the Python-list mailing list