Is it possible to drag something from a qt widget onto a maya modelEditor?
I got the QWidget for the modelEditor (i think) and it says acceptDrops() is True, but wont let me drop anything. I’m assuming it has to do with the mimeData. Has anyone explored this type of functionality before?
Thanks
Assuming you’re running on a Windows machine it’s quite easy to construct the right mime data object.
Use QMimeData to provide all information that a drop in Maya needs to be accepted.
So far, that’s what works pretty well for me. (works also for 3dsmax & Photoshop)
mime_data = QMimeData()
mime_data.setData("application/x-qt-windows-mime;value=\"FileNameW\"", r"c:\maya_files est01.mb")
mime_data.setData("text/uri-list", "file:///%s" %(r"c:\maya_files est01.mb"))
file_url = QUrl("file:///%s" %str(self._selectedAsset["sourceFile"]))
mime_data.setUrls([file_url])
drag = QDrag(self)
pxm = QPixmap(r"c:\images humb_for_drag.png")
drag.setPixmap(pxm)
drag.setMimeData(mime_data)
dropAction = drag.start(Qt.CopyAction)
if dropAction == Qt.MoveAction:
self.close()
But you have to set the viewport to accept drop-data type too, right?. How?
If you thrown an obj-file into maya viewport, it will automatic open (or import) it into scene. How can i change it behavior to accept the drop in file as reference file?
Thanks