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

Mudcat mnations at gmail.com
Sat Dec 13 21:45:43 EST 2008


On Dec 12, 6:17 pm, David Boddie <da... at boddie.org.uk> wrote:
> That's correct, retrieveData() is a protected function in C++ and the
> QMimeData object was created by the framework, not you, in this case.

Ah, well that explains it. Figured as much but was hoping maybe I was
trying to access it incorrectly.


> You could use the data() method to get the serialized data then try to
> extract the list item-by-item using the QDataStream class, or perhaps
> PyQt has a convenience function to unpack the items.

I tried to get info back using data() but kept getting null values.
Same goes for the items() function which is fed with mimeData and is
supposed to return a list. From the documentation it appeared that was
supposed to be the middle-man to re-convert the data. I know the data
existed because I could drag/drop elements from one treeWidget to
another but still couldn't get data back from the target widget.


> Alternatively - and this is a bit speculative - perhaps you can copy
> the data to another QMimeData object which you have created, and use
> its retrieveData() method to retrieve the items.

I started down the path of creating my own MimeType but then realized
it was quicker to just override the drop() function and grab the
selected items from the source widget, just letting the mime data
disappear into the ether. A little klugey but deadline is fast
approaching. However I'll give the pyqt mailing list a shot. I didn't
know there was one just for pyqt.

Thanks for all the help,
Marc






More information about the Python-list mailing list