[Qt-interest] Drag and drop in QTreeView - reordering rows

Nesbitt none at none.no
Fri Oct 15 20:01:09 CEST 2010


Hi

I have tree model (with drag and drop implemented) based on editable tree 
model example. 

I would like to be able to reorder and/or reparent rows in my model. I am 
using beginMoveRows and endMoveRows in dropMimeData. Reparent works ok. 
But I have problems with reorder rows (moving rows up or down in the same 
parent). 

I was playing with dragDropOverwriteMode. When it is set to true (as 
recommended for TreeViews) I cannot choose space between rows so I cannot 
reorder rows at all.

When dragDropOverwriteMode is set to false I am able to choose space 
between rows but when I try to reorder rows it replaces existing row with 
the one I have dropped. 

For now dragDropOverwriteMode is set to false and I am ignoring first 
attempt to remove row that occurs after drag and drop. It works ok but I 
dont like this workaround and I am curious if there is better solution for 
reorder rows in hierarchical models.

Regards Nesbitt



More information about the Qt-interest-old mailing list