With some serious trial and error I found a solution which is actually 
quite straight forward, as its mostly the case...
So the main thing is to register the event with the main app in my case 
maya.

main_win = mhelper.getQMayaMainWindow()
main_win.installEventFilter(drop_filter)  


and then in the event filter I need to check which event is being called:

def eventFilter(self, obj, event):
        self.obj = obj      
        
        if event.type() is event.DragEnter:
            self.mouse_button = QtGui.QApplication.mouseButtons()
            event.accept()
               
        if event.type() is event.Drop:
            library_w = event.source()
            if self.mouse_button == QtCore.Qt.LeftButton:

            ....


and that is all of the magic..
Thanks Marcus and Justin






On Monday, April 4, 2016 at 6:19:58 PM UTC+1, Marcus Ottosson wrote:
>
> Hey Arvid,
>
> It sounds like you’ve got the gist of it. You’ll need to listen for both 
> DragEnterEvent, to determine whether or not to accept the event, and 
> DropEvent to decide what to do with it in case it gets accepted. Some 
> widget will be more difficult to install such an event filter in than 
> others; most prominently the main viewport. I’d probably try installing it 
> onto the main application first, (PySide.QtGui.qApp) and go from there.
>
> If you haven’t already had a look at this, I’d suggest taking a moment to 
> read it through.
>
>    - https://doc.qt.io/qt-4.8/dnd.html (Dungeons & Dragons.html?) 
>
> ​
>
> On 4 April 2016 at 16:11, Arvid Schneider <[email protected] 
> <javascript:>> wrote:
>
>> Hello, me again with Qt stuff..
>>
>> So I have a QListWidget with lots of thumbnails of textures, hdrs, assets 
>> etc etc. 
>>
>>
>> <https://lh3.googleusercontent.com/-d2gGZcBFCIg/VwKDxU-gwnI/AAAAAAAAI-A/o8H9nbGyKsoIM9VQQj9WrgQU2nJ0UKiNQ/s1600/Screenshot%2Bfrom%2B2016-04-04%2B16%253A09%253A48.png>
>> I want to be able to drop this thumbnail into any QApplication ( for now 
>> Maya) and then I can call certain functions to create image nodes, lights, 
>> etc etc. 
>> I read about MimeData, and I read about eventFilter and install 
>> eventFilter. But I have no idea on how to get it to work, so Maya accepts 
>> drops and registers them. So I can call my functions.
>> Any help as always appreciated. 
>>
>>
>>
>>
>>
>>
>>
>> Arvid
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/fd8bcc5a-7e01-4e03-bb55-e3ddf0d15c15%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/fd8bcc5a-7e01-4e03-bb55-e3ddf0d15c15%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> *Marcus Ottosson*
> [email protected] <javascript:>
>

-- 
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/91a9b01f-250a-4fb5-9b49-c026ffd7e542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to