Skip to content

Instantly share code, notes, and snippets.

@oglops
Last active March 16, 2022 18:41
Show Gist options
  • Select an option

  • Save oglops/dbbb0e8db70dc0fb7b2ae6809deafb71 to your computer and use it in GitHub Desktop.

Select an option

Save oglops/dbbb0e8db70dc0fb7b2ae6809deafb71 to your computer and use it in GitHub Desktop.

Revisions

  1. oglops revised this gist Mar 16, 2022. No changes.
  2. oglops revised this gist Mar 16, 2022. No changes.
  3. oglops created this gist Mar 16, 2022.
    27 changes: 27 additions & 0 deletions mute_screen_grab_drag.py
    Original 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)