I should note that more specifically, for getting this to work currently, I create a clone of my original element in the dropMimeData function of my model, and put that clone in place. Qt Deletes my original automatically after the fact. I know this is happening because if I do a debug inspection of my data at the end of dropMimeData, the original element is still there. Also, if I just reparent the item, Qt deletes it after it has been reparented. I suspect that removeRows is is being called internally on the original dragged element, but I can't see any way to override that behavior, and am hoping that's just one of those things that's not documented but is still possible.
As I said, it's easy enough to design around, but it doesn't feel like I should have to, with how long Qt's been around. On Wed, Mar 11, 2015 at 2:00 PM, Joe Weidenbach <[email protected]> wrote: > Hey folks, > > More of a conceptual question here, as I've got this working at this > point, but it feels like I had to do some ugly workarounds, which I can > design around in the future, but would rather not have to. > > As I'm understanding it, Qt's Drag and Drop functionality in Models and > Views is based on primarily taking elements from one model and moving them > to another. When I am working in a Tree View, for example, and I want to > reorder or reparent items, I basically have to clone my item that I'm > dropping and put it in the model where I want it, after which Qt deletes > the original. This makes sense based on the usual use of drag and drop to > go from one view to another. > > The question is, is there a way to set things up so I can just move an > item? It's easy enough to build a data model that supports serializing and > then making a new item that is a duplicate of the old, but it seems like > extra work (both on the coding and on the processing sides) as compared to > just changing the parent or sort index. > > Just curious. > > Thanks, > > Joe > -- 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%3Da5xsK6hwc5mtT9uL1DvgQKQe%2Bx0KsNxuOiryO3NDkpFEA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
