Ok, I got it. If you have been wandering around the net looking for the answer in how to set up your mime data so that windows applications accept it from your Qt app here is how I got it working.
Windows requires the filepath to be prepended* file:///* and by using QUrl.fromLocalFile() we can get this easily. *def mimeData(self, files): data = QMimeData() urls = list() for f in files: urls.append(QUrl.fromLocalFile(f)) data.setUrls(urls) return data* // Ben On Friday, 15 January 2021 at 09:38:33 UTC+1 Benjam901 wrote: > *From Justin:* > > *Well if you are now setting both url and text mime types, and the target > is still rejecting the drop, the only other thing I can think of is that it > is looking at the drop action (copy vs move vs targetmove) and still > rejected it.* > > *https://doc.qt.io/qt-5/qt.html#DropAction-enum > <https://doc.qt.io/qt-5/qt.html#DropAction-enum>* > > *https://doc.qt.io/qt-5/qabstractitemview.html#defaultDropAction-prop > <https://doc.qt.io/qt-5/qabstractitemview.html#defaultDropAction-prop>* > > *If you create your own qt window app to accept the drop and print the > mime, does it work? Is it even your own qt target windows that dont work, > or just some other windows apps?* > > On Thursday, 14 January 2021 at 23:16:42 UTC+1 Benjam901 wrote: > >> Hello all, >> >> I am starting a dedicated thread for this in case it gets solved and >> someone comes along and finds the solution. >> >> I have an application that sets up a QSqlTableModel with filepaths and >> names etc. On Mac OS dragging from QSqlTableModel by simply overriding >> mimeData() works a treat but windows is another story. >> >> I have tried the following for windows with no luck: >> >> >> >> >> >> >> >> *mime_data = >> QMimeData()mime_data.setUrls(files[0])mime_data.setText(files[0])b = >> bytearray()b.extend(map(ord, files[0]))mime_data.setData('text/plain', >> QByteArray(b))* >> >> Gist of my basic sqltablemodel: >> https://gist.github.com/ben-hearn-sb/61993bf1bf8aa403c6a237d56188667f >> >> Has anyone ever gotten tis behaviour to work before? I googled around and >> someone 12 years ago solved it using pywincom (or so they claim) but I >> cannot get his example to work, it just kills my app wholesale: >> >> https://www.qtcentre.org/threads/16097-Dragging-to-windows-(pyqt) >> >> any help would be much appreciated on this! >> >> // Ben >> > -- 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/6967d624-9e14-4c56-9909-4d6eec4f117dn%40googlegroups.com.
