I just had to deal with this and itโs a pain in the ass, but here's what to do:
You need to set eventFilter to a subclass of ListWidget and then watch the ChildRemoved event. This event covers movement as well as deletion, so it should work for reinstalling items with drag and drop inside the list.
I am writing my Qt in C ++, but here is the pythonification version:
class MyList(QtGui.QListWidget): def __init__(self): QtGui.QListWidget.__init__(self) self.setDragDropMode(self.InternalMove) self.installEventFilter(self) def eventFilter(self, sender, event): if (event.type() == QEvent.ChildRemoved): self.on_order_changed() return False # don't actually interrupt anything def on_order_changed(self): # do magic things with our new-found knowledge
If you have another class containing this list, you may need to move the event filter method. Hope this helps, I know that I had to deal with it for a day before I figure it out.
Trey stout
source share