Ya actually there are a number of ways to work with drag and drop,
depending on what classes you are using. Like you have said, there is
dropMimeData on the model if you want to handle it there, and startDrag on
the view if you want to handle it there, and then more manual approaches
with starting your own drag in the mouse events.


On Thu, Mar 12, 2015 at 1:08 PM Joe Weidenbach <[email protected]> wrote:

> Just an update; from my research, it looks like I need to subclass
> QTreeView to do this.  The default implementation of startDrag from
> QAbstractItemView apparently is what will delete the original item after
> everything's said and done, which checks out with reading the source code
> of qabstractitemview.cpp.  So far, I've made do with a raw QTreeView.  It
> looks like I'll have to subclass that so I can override startDrag and not
> have it remove the row.
>
> On Wed, Mar 11, 2015 at 3:41 PM, Joe Weidenbach <[email protected]> wrote:
>
>> I'm glad we're all on the same page.  Looking into Justin's mention of
>> "taking" the item, I do see that functionality in the Convenience Widgets
>> (QTreeWidget, etc), but not in QAbstractItemModel.  Same with Marcus'
>> suggestion of moveRow(). I might be looking at the wrong documentation...(
>> http://srinikom.github.io/pyside-docs/PySide/QtCore/
>> QAbstractItemModel.html or http://qt-project.org/doc/
>> qt-4.8/qabstractitemmodel.html).
>>
>> I haven't gone into beginMoveRows yet, mainly as in dropMimeData I don't
>> have an index or parent for the original element (I think the model manages
>> that internally), although I can get the data from it (I look up the
>> element in my underlying data model using the serialization I put into the
>> MimeData).  I'm doing the reordering exactly as Marcus described as well,
>> although I'm currently inserting my cloned item.
>>
>> I think I could serialize the index data in mimeData to reconstruct the
>> parent index in dropMimeData, that might be my next move so I can try
>> working with beginMoveRows and see if it's any cleaner.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/CAM33%3Da6U7RYaWUVBFaxCLuhzMzWAB%
> 3DYU_UPOdg0A0CetR%2BH9KA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da6U7RYaWUVBFaxCLuhzMzWAB%3DYU_UPOdg0A0CetR%2BH9KA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0rK435D%2BC47gx1AgSJuRxhbm7ZfQSzKZnNzaeJgxpuqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to