[PyKDE] Dragdrop with a QTreeView?

Andreas Pakulat apaku at gmx.de
Wed Jun 14 00:18:06 BST 2006


On 13.06.06 15:53:40, Adam Tenderholt wrote:
> 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).

Hmm, this sounds like something I already reported to TT, however my
example uses only 1 view and its a listview. The problem here is that
the items are only moved visually and not on the underlying model. Also
the move brings items on top of each other, somehow "merging" them.

> 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.

Yeah, you could try to use the same treeview+model on the other side,
but I guess that will not work...

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

Well, the TT support sounded like there are a few issues with moving,
which will be fixed in Qt4.2 so I guess you have to wait til that one
comes out...

I find it rather sad that Qt4 has so many bugs atm and that a lot of
them can only be fixed with Qt4.2...

Andreas

-- 
Good news.  Ten weeks from Friday will be a pretty good day.




More information about the PyQt mailing list