Using PySide/PyQt, I construct a draggable label that works exactly how I want:
Qt Code:
  1. class DraggableLabel(QtGui.QLabel):
  2. def __init__(self, txt, parent):
  3. QtGui.QLabel.__init__(self, txt, parent)
  4. self.setStyleSheet("QLabel { background-color: rgb(255, 255, 0)}")
  5. def mouseMoveEvent(self, event):
  6. drag=QtGui.QDrag(self)
  7. dragLabMimeData=QtCore.QMimeData()
  8. drag.setMimeData(dragLabMimeData)
  9. drag.exec_(QtCore.Qt.MoveAction)
To copy to clipboard, switch view to plain text mode 
Unfortunately, I do not understand what is going on with QMimeData, and fear I am going to run into big problems when I use similar code in real-world examples.

In particular, I am worried that my reimplementation of mouseMoveEvent creates an instance of QMimeData without any argument passed: QtCore.QMimeData(). Is this normal? Within more complex widgets will I be OK if I keep doing that within the relevant event handler: will the program automatically create the right type of MIME data for dragging and dropping?

The reason I fear I am missing something is because at the Qt Drag and Drop documentation, it has lines of code like:
Qt Code:
  1. mimeData -> setText(commentEdit->toPlainText());
To copy to clipboard, switch view to plain text mode 
which seems decidedly not like just letting the program take care of things within a reimplementation of an event handler.

Also, the QMimeData documentation discusses convenience functions to test, get, and set data, but those are for standard data types (e.g., text, urls). I have found no clear way to define such convenience functions for widgets like my draggable QLabel. Am I missing it? Is there a simple way to find out if I am dragging around a widget of type X?

Note I posted this also at Stack Overflow:
http://stackoverflow.com/questions/2...itrary-widgets