I implemented some custom drag+drop in the standard way. Part of the dragging code:
drag->exec();
...
QDrag* drag = new QDrag(this);
drag->exec();
...
To copy to clipboard, switch view to plain text mode
Now I am wondering: Who owns the QDrag* object 'drag'?
It seems to me that I do, and I have to do delete the drag object before returning:
drag->exec();
...
delete drag;
...
QDrag* drag = new QDrag(this);
drag->exec();
...
delete drag;
...
To copy to clipboard, switch view to plain text mode
However, in none of the Qt drag+drop examples this is done. They just let the pointer go out of scope and dont bother about it!
(note that the 'this' passed to the constructor is not a 'QObject* parent' but the source of the dragging.)
https://doc.qt.io/qt-5/qtwidgets-dra...idget-cpp.html
The documentation doesnt say anything special either.
Who owns it? Do I have to delete it or not?
Bookmarks