[PyKDE] Dragdrop with a QTreeView?

Adam Tenderholt atenderholt at gmail.com
Tue Jun 13 23:53:40 BST 2006


I've subclassed QAbstractItemModel (using the puzzle and other
itemview examples as starting points) and have it mostly working in a
QTreeView. I can drag and drop items from one QTreeView instance into
itself and another instance. supportedDropActions() returns
QtCore.Qt.MoveAction (but not CopyAction) so I'm expecting move items
to disappear from the source view and appear in the target view. I
reimplemented removeRow() or removeRows() because my understanding is
that at least one of these are called once the drop is completed.
However, if i put a print state at the very top of these functions
nothing is printed (ie. it's not called).

I tried the following combinations of removeRow() and removeRows():

removeRow() and no removeRows() - read this suggestion on some site
removeRows() and no removeRow()
removeRow() and removeRows()

I haven't been able to find a working example that does what I want.
The puzzle example is the closest I've found for drag and droping from
a QTreeView, but it's target is a custom widget so it's not exactly
the same.

Does anyone have some ideas of changes I should make, or sample code
with working MoveAction between two different QTreeViews?

Thanks,

Adam




More information about the PyQt mailing list