I just provided an answer for this question and wanted to provide a working example when I noticed that newly created QMimeData
instance returned by QList
There is a memory leak only if you forget to delete the pointer returned by mimeData()
. You have to manage the ownership as with any pointer.
For instance, if you pass the mimeData()
returned pointer to a QDrag
object using setMimeData()
, he will take ownership of it, and will take care of deleting it at the end of the drag operation. There is no memory leak in this case.
See : http://doc.qt.io/qt-5/qdrag.html#setMimeData