Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Non-virtual destructor in QNetworkAccessManager
ravehanker last edited by
I'm subclassing QNetworkAccessManager to provide for a custom protocol as per http://doc.trolltech.com/qq/32/qq32-webkit-protocols.html and I see that the destructor for QNetworkAccessManager is non-virutal(http://doc.qt.nokia.com/4.7-snapshot/qnetworkaccessmanager.html#dtor.QNetworkAccessManager).
I can see that this will not work if do not set a parent for the object and hold a reference to it as a QNetworkAccessManager.
Will the object be destroyed properly if I set a parent to it? Does QObject's destructor handle children with non-virtual destructors properly?
goetz last edited by
QNetworkAccessManager inherits from QObject. The latter has marked it's destructor as virtual, so subsequently the destructors of all derived classes are virtual too.
See "FAQ 20.7":http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7 of the C++ FAQ for an explanation.
The object will be destroyed properly when it has a parent.