[PyQt] Drag & Drop with QTreeWidget
Baz Walter
bazwal at ftml.net
Fri Dec 11 20:46:01 GMT 2009
NARCISO, Rui wrote:
> Hi again
>
> Your approach worked nicely but when I tried to enable sorting using:
>
> self.setSortingEnabled(True)
> self.sortByColumn(0, QtCore.Qt.AscendingOrder)
> I get a segmentation fault.
>
> If i disable the sortByColumn then it works.
>
> How then to set the sorting using column 0 by default ?
actually, i now think my approach was too crude. the trouble with using
rowsInserted is that it is called every time items are added or moved
(or sorted).
what is really needed is a way to add special handling only for dropped
items. unfortunately, there does not appear to be an obvious way to
detect what items were dropped and where. so i think the only reliable
way to get the behaviour you want is to reimplement qtreewidget's drop
event handling (which is probably doable, but not easy).
More information about the PyQt
mailing list