[Qt-interest] Drag & Drop of hierachical items in a TreeView

Stephen Kelly steveire at gmail.com
Mon Nov 30 13:27:09 CET 2009


Daniel Price wrote:
> 
> > It is odd that the children are lost. How are you doing the actual move?
> 
> I sent an email to Nokia support and they provided an example - you have
> to cache the child items recursively using PersistantModelIndexes and then
> re-constitute the tree after the drop using insertRow() etc. It's a bit
> messy but it works.
 
Good that it works, but I still think it really shouldn't be necessary.

> 
> > If you are using Qt4.6, try the beginMoveRows/endMoveRows api. It should
> > not be necessary to reconstruct the entire tree if you do that.
> 
> I'm using 4.5.2. Is this a new feature of 4.6? It preserves the children?
> 

Yes it's new in 4.6. I contributed the feature. It's really just convenience 
for updating persistent indexes correctly, and ensuring that a move is 
valid. When moving rows, child indexes should not be affected, but I would 
be interested in seeing the example and solution you came up with.

All the best,

Steve.





More information about the Qt-interest-old mailing list