Last active
March 16, 2022 18:41
-
-
Save oglops/dbbb0e8db70dc0fb7b2ae6809deafb71 to your computer and use it in GitHub Desktop.
Revisions
-
oglops revised this gist
Mar 16, 2022 . No changes.There are no files selected for viewing
-
oglops revised this gist
Mar 16, 2022 . No changes.There are no files selected for viewing
-
oglops created this gist
Mar 16, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ def startDrag(self, supportedActions): print('start drag') listsQModelIndex = self.selectedIndexes() if listsQModelIndex: # dataQMimeData = self.model().mimeData(listsQModelIndex) # insert fake x-maya-data dataQMimeData = QtCore.QMimeData() encoded = QtCore.QByteArray() # failed attempt to cheat maya # import pickle # encoded = pickle.load( open( "/tmp/fake", "rb" ) ) # dataQMimeData.setData('application/x-maya-data', encoded) dataQMimeData.setData('text/plain', 'random text') print('current formats', dataQMimeData.formats()) if not dataQMimeData: return None dragQDrag = QtGui.QDrag(self) # disable widget screenshot # dragQDrag.setPixmap(QtGui.QPixmap('test.jpg')) # <- For put your custom image here dragQDrag.setMimeData(dataQMimeData) defaultDropAction = QtCore.Qt.IgnoreAction if ((supportedActions & QtCore.Qt.CopyAction) and (self.dragDropMode() != QtWidgets.QAbstractItemView.InternalMove)): defaultDropAction = QtCore.Qt.CopyAction; dragQDrag.exec_(supportedActions, defaultDropAction)