[Qt-interest] Drag & Drop with custom Model in QTreeView

Benjamin ikipou at gmail.com
Sun Dec 14 08:55:28 CET 2008


2008/12/14 Sebastian Fischer <creat at gmx.net>

>
> Now for the actual issue:
> I have a very confusing problem with Drag & Drop. I have reimplemented
> a tree model based on QAbstractItemModel and use the default
> QTreeView to display the contents. It has 3 columns, but only the
> first column has the Qt::ItemIsSelectable flag set. I want to be able
> to move items to a new location.
> Now everything works fine if I set the QTreeView's selectionBehavior
> to SelectItems EXCEPT the moved items aren't removed (reading a bit of
> Qt code it turns out that removeRows is only called if complete rows
> are selected).
>

This sounds like a reasonable behavior to me. To remove the complete row,
you can just reimplement the Drag&Drop behavior by creating a QDrag
yourself, and delete the row when the drag succeed.

Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081214/c4b7a402/attachment.html 


More information about the Qt-interest-old mailing list