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

BRM bm_witness at yahoo.com
Fri Oct 15 20:14:40 CEST 2010


I haven't done Tree Models and such, but I know when I worked with the List View 
stuff for something similar I had to be very careful what order I applied the 
changes in
since once I modified an index later indexes would no longer be valid - e.g. 
remove row X then row X+1 becomes X but references in the range selection spec 
still have X+1.
Perhaps I was doing it differently than I should have (that was early on in my 
Qt experience) so may be there is a way to avoid that.

HTH,

Ben



----- Original Message ----
> From: Nesbitt <none at none.no>
> To: qt-interest at trolltech.com
> Sent: Fri, October 15, 2010 2:01:09 PM
> Subject: [Qt-interest] Drag and drop in QTreeView - reordering rows
> 
> 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
> _______________________________________________
> Qt-interest  mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 



More information about the Qt-interest-old mailing list