On Sat, Apr 8, 2017, 11:50 PM Rudi Hammad <[email protected]> wrote:

> Thanks Justinn, that was it.
>
> I guess that the next step is to be able to insert it before or after. The
> treeWidget by default highlights a line under or above, to indicate where
> the insertion will be done.
> At the moment myInserted item is taking the place of the one that is
> dropped one. But I guess that it won´t be simple to do, since I will have
> to create methods to mimic this behavior?
>

Stepping back a sec to your previous questions and goal, did you actually
want to customise the drip behavior beyond just filtering what can and
can't be dropped? I noticed you don't call the super methods in your
reimplemented event handlers. If you determine you don't want to handle the
item you can ignore it in the move event. Otherwise you could let the item
drop using the default implementation.

But if you really do need custom drop logic because you want to decide what
exactly to copy to the new item, and where it goes, then yea you would have
to handle the stuff like if it's dropped as a sibling of the item or as a
child. Or if it really does replace the previous item.

To determine if you should make it a sibling drop above or below you can
get the visual rect of the drop target item and check where the drop event
falls in relation to the center y

http://doc.qt.io/qt-4.8/qabstractitemview.html#visualRect




> My other question is if I am doing right the dropEvent(), because all I am
> doing is creating a new item and copying the text of the item in the left.
> I will also copy the data stored as userRole.
> But is this a real drag and drop? I am just creating a newItem and copying
> the text and data of the item selected in the left.
>

That's all drag and drops are. A widget receives a drip event with mime
data and they interpret it somehow. Then the caller that initiated the drag
receives the results of whether it was accepted and which action was used.
So if it were a move, then the caller knows to delete their instance. But
for a copy, the receiver is applying a copy of data.


> R
>
>
> El sábado, 8 de abril de 2017, 4:01:21 (UTC+1), Justin Israel escribió:
>
> If you now have the drop position from the QDropEvent, then you should be
> able to inspect the item under the position via itemAt
>
> http://doc.qt.io/qt-4.8/qtreewidget.html#itemAt
>
> From there you can choose how you want to insert
>
> Justin
>
> On Sat, Apr 8, 2017, 4:10 AM Rudi Hammad <[email protected]> wrote:
>
> sorry, badLink. This is the one --> https://pastebin.com/S6DZd5MM
>
>
> --
> 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/dbe817a4-5b86-480f-8e85-6073b1c2e88b%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/dbe817a4-5b86-480f-8e85-6073b1c2e88b%40googlegroups.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/830582ed-cbce-4d87-87f6-ef2d4ba5038f%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/830582ed-cbce-4d87-87f6-ef2d4ba5038f%40googlegroups.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/CAPGFgA3NctJ-SH0ztK_WKvyOOgM68D7Lr_6%3D0%3D754GXoVXN2gg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to