Author Topic: Substance Designer Drag and Drop with Pyside2  (Read 1851 times)

I was wondering if anyone could give an insight if it's possible to implement some drag and drop functionality with PySide2. I have a custom window setup and working. However I'm trying to implement the ability to drag and drop items from my window into Substancer Designer.

The window is already capable of drag and drop in other software packages I just can't find any info on if some particular data is required in a QMimeData object for example. Also QDrag.exec_() is only ever returning an IgnoreAction. Any help would be appreciated as it would be a nice feature to have.



It depends on where exactly you're trying to drag/drop.

I provided this slightly hackey solution a while back for the node graph, see if it points you in the right direction.,30012.msg115891.html#msg115891

I didn't bother looking deep enough into capturing the QMimeData, but it should be possible for you to install an eventFilter on the Designer widget* containing the dropEvent and capturing the mimeData details theory.

Alternatively, you could even install an eventFilter to the widget that accepts and processes your custom mimeData from your application's dropEvent, before/after processing the built in mouseDropEvent.

I no longer have access to the QT version of Designer so there's no way for me to test it.

* See the "Testing..." section of the code on how to capture the widget and their class names (objectName isn't being used).
Last Edit: February 18, 2020, 11:57:17 pm

Thanks for the respone NevTD,

It's custom items in a QListView they mostly represent .sbsar files or image files. Thanks for the direction, seems very useful, I should be able to get something working with it.

I may provide some details on here when I have time to figure it out.