[PyQt] QTreeView DragDropMode (Copy vs. Move)

Bart Kroon pyqt at tarmack.eu
Sat Apr 21 13:03:02 BST 2012


Sorry it took me so long, I was quite busy.

My solution is used for moving items internally in one model. From your 
earlier mails I may have gotten the wrong idea. It seems you need to move the 
items from one model to another. Is this correct?

Am I correct in assuming that your source model is some sort of list of items 
the user can chose from and the target represents the users selection of said 
items?

For doing that you would probably need to make the models communicate in 
some way. So that when the items are placed in the target model it can signal 
the source model that it needs to remove the dragged items.

In my program some models work as a Qt model and python list at the same time. 
The Qt model interface is used for GUI interaction and the python list 
interface is used to edit the underlying data programmatically.

You can find my models in the models subdir in this project: 
https://github.com/tarmack/Pythagora


On Thursday 19 April 2012 14:13:21 hosscomp wrote:
> More progress.  I now have the two MineData types working so that a node
> dropped into the target tree is created with a different MIME_TYPE and in
> the dopMimeData method of the target model I have at the bottom:
> 
> . . .
> if (mimedata.hasFormat('target_type')):
>    self.removeRow(row,parentIndex)
> 
> It does go through this removeRow for internal drags with no errors, but
> removes the new item instead of the old one.
> If I comment those two lines out it creates the new item and leaves the old
> one there also.
> 
> More digging. Wish I had connectivity on that computer so I could send a
> working example.
> 
> --
> View this message in context:
> http://python.6.n6.nabble.com/QTreeView-DragDropMode-
tp4680293p4899744.html
> Sent from the PyQt mailing list archive at Nabble.com.
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list