On Thu, Nov 10, 2016 at 6:21 AM Alec Fredericks <[email protected]>
wrote:

> Hi there,
> I think I'm misunderstanding something fundamental about QT and Maya UI
> interactions.
> I've created a small PyQt window that contains some tabs and, in one of my
> test tabs, I have a grid populated by a couple of custom QLabel widgets.
> Those widgets are the bits I want to drag into the Maya viewport and, in
> turn, execute some code when the drop is recognized.
>
> In my custom QLabel, I have a dragEnterEvent and mousePressEvent.
>
> For the main Maya window, I install an eventFilter that checks for
> QEvent.Enter, DragEnter and Drop.
>
> The eventFilter only ever seems to fire off the QEvent.Enter code but
> never DragEnter or Drop.
>

I would try not accepting the event + returning True in your block that
handles QEvent.Enter. That indicates that you want to swallow the event and
the viewport will never see it it to do any custom handling. Does it start
working when you ditch that block or at least just return False? I have
viewport code that looks similar to your DragEnter and Drop blocks.

Also, your source label widgets shouldn't need a dragEnterEvent defined on
them. That is for the case where they want to accept things dropped on them.


>
> Here's my eventFilter:
>
>     def eventFilter(self, receiver, event):
>         self.receiver = receiver
>
>         if event.type() is QEvent.Enter:
>             print("ENTERED, FOOL!")
>             self.mouse_button = QApplication.mouseButtons()
>             event.accept()
>             return True
>
>         if event.type() is QEvent.DragEnter:
>             print("DRAG ENTERED!")
>             self.mouse_button = QApplication.mouseButtons()
>             event.accept()
>             return True
>
>         if event.type() is QEvent.Drop:
>             print("DROPPED")
>             library_w = event.source()
>             if self.mouse_button == Qt.LeftButton:
>                 print 'you dropped the bomb.'
>                 return True
>             else:
>                 print 'nothing dropped.'
>
> Is there something more I need to do to get DragEnter and Drop to function
> in the eventFilter?
>
> Thanks,
> Alec
>
>
> --
> 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/4565ad58-3009-4ef6-a9ae-3a28e390aab2%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/4565ad58-3009-4ef6-a9ae-3a28e390aab2%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/CAPGFgA2hs0V1gpp8W1OVz1M9%3DuYCnPsfqQNtBdQ2MHpBmru6dA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to