How can I break parent-child ownership for a QObject? It seems that there is no longer an explicit way of doing this. Is it enough to call
QObject::setParent(NULL)
According to the Qt5 Doc
You can also delete child objects yourself, and they will remove themselves from their parents.
You're correct. To make a QObject
an orphan, simply do
// on C++11 compiler
object->setParent(nullptr);
// on a pre-C++11 compiler
object->setParent(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With