aknuds1
aknuds1

Reputation: 67987

How do I disable support for reordering by dragging and dropping within QTreeWidget?

I have enabled dragging and dropping within a QTreeWidget, but I don't want to allow reordering of items by dragging them around. How do I disable such reordering?

I've basically enabled dragging and dropping within the QTreeWidget like this:

from PyQt5 import QtWidgets


class _TreeWidget(QtWidgets.QTreeWidget):
    def __init__(self):
        super().__init__()
        self.setDragDropMode(self.InternalMove)

Upvotes: 1

Views: 664

Answers (1)

aknuds1
aknuds1

Reputation: 67987

Looks like reordering by dragging is disabled implicitly when enabling sorting (via setSortingEnabled), so this is at least a partial solution. In my case user sorting should be enabled anyway, so it's good enough for me.

Upvotes: 1

Related Questions