[SOLVED, moved] Drag from another application and drop to a PySide app?
I am trying to implement a dropEvent in a PySide application to open a file when someone drags it from the file explorer and drops it in the PySide application.
So I added self.setAcceptDrops(True) in the init of my MainWindow and implemented a dropEvent like that:
def dropEvent(self, *args, **kwargs):
However, I cannot drop to my application.
The cursor is a ∅ that doesn't want me to drop there...
How can I drop something in a PySide application?
Note: I tried adding setAcceptDrops(True) to inside widgets, it doesn't work neither.
You also have to implement the "dragEnterEvent()":http://doc.qt.nokia.com/4.7/qwidget.html#dragEnterEvent to tell the window system which drags you actually want to accept.
Oh yeah I didn't notice I have to "accept" the drag first, thanks ;)
If it helps anyone who was also wondering how to do a drag an drop in PySide, here is my working code:
def dropEvent(self, event):
def dragEnterEvent(self, event):
m = event.mimeData()
self.dropFile = m.urls().toLocalFile()