You have to implement both dragEnterEvent
and dragMoveEvent
. See here for another similar question
This seems to do what you need rather short and elegant :)
class DragDropListWidget(QtGui.QListWidget):
def __init__(self, type, parent=None):
super(DragDropListWidget, self).__init__(parent)
self.setDefaultDropAction(QtCore.Qt.MoveAction)
self.setDragDropMode(QtGui.QAbstractItemView.DragDrop)
self.setAcceptDrops(True)