I don't recall there being too much variation in the way you retrieve the
path of a dropped file. You just check for the urls, and for text. It's up
to the underlying platform specific code to deliver the mime info as part
of its drop.

On Fri, 13 Mar 2015 9:48 PM Fredrik Averpil <[email protected]>
wrote:

> Hi,
>
> I've created a custom QLabel class which allows dropping a file onto it.
> But I'm having issues with fetching the filepath of the dropped file when
> dropped from anything but a Windows drive letter. So for example if you
> drag and drop a file from a network share (which has not been mapped to
> drive letter), I'm not getting the absolute full path. Also, on Mac OS X my
> code does not seem to work at all.
>
> I'm totally new to the whole drag and drop concept and I feel I haven't
> had the time to read up on this prior to dig into code. So I'm a little
> lost on the concept side of things.
>
> Do I have to check for the filepath of the dropped file in several
> different ways? This seems somewhat odd...
>
> Any tips or ideas on how to deal with this are very much welcome.
>
> Cheers,
> Fredrik
>
>
> This is the code I have currently:
>
> class DropableQLabel(QtGui.QLabel):
>     def __init__(self, parent):
>         super(DropableQLabel, self).__init__(parent)
>
>         self.skalman = parent.skalman
>         self.skalman.browser = parent
>
>         self.setFixedWidth(300)
>         self.setFixedHeight(169)
>         self.setFrameShape(QtGui.QFrame.Box)
>         self.setAlignment(QtCore.Qt.AlignCenter)
>         self.setAcceptDrops(True)
>
>
>     def dragEnterEvent(self, event):
>         print 'Entered droppable area'
>         if event.mimeData().hasUrls():
>             event.acceptProposedAction()
>         else:
>             super(DropableQLabel, self).dragEnterEvent(event)
>
>
>     def dropEvent(self, event):
>         if event.mimeData().hasUrls():
>             for url in event.mimeData().urls():
>                 print url.path() # this is not always an absolute filepath
>
>
>             event.acceptProposedAction()
>         else:
>             super(DropableQLabel,self).dropEvent(event)
>
> ​
>
> --
> 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/CAD%3DwhWP6rn%2B6-A8dd4p1TA6gRu3FSDw%2Bc5vWsfJ1gmfOUUWdmQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWP6rn%2B6-A8dd4p1TA6gRu3FSDw%2Bc5vWsfJ1gmfOUUWdmQ%40mail.gmail.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/CAPGFgA0xf%3DG42_%3D%3DHo8YisEH%2Bg4DmDEpx%2BNNnbEVAVySp%2B7DOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to