Post-facto inheritance
Now, I didn't expect this to work at all!
A QlistView is a sort of tree widget, and is drag&drop enabled.
The trick is, you have to reimplement dragObject() so it returns a draggable thingie after you drag something.
But, since I am using designer to draw the forms, I have to use a real QListView, not a child class.
Conundrum? Custom widget in designer? Not with python!
- def myDragObject(self):
-
return QTextDrag("something",self)
self.tree.__class__.dragObject=myDragObject
And that works! I know it should work in python, but QListView is implemented in a C++ module!
The guys that did PyQt really made it well.
Thanks for the demo code. I suspected that such a tweak should exist, but I was not sure _how_ this could be done.
Since it is also possible to use QUriDrag, QImageDrag and so on, implementing simple dNd with applications (I use it to drag "filenames" from a PyQt application to beep-mp) becomes almost trivial
greets