Important: Please read the Qt Code of Conduct -

[SOLVED] Will parent delete QAction created with new QAction(this)?

  • Hi all,
    have following question answer of which I can't find in Qt docs:
    If I create QAction instance like:
    @QAction * act = new QAction(this);@
    and this is an subclass of QObject(in my situation it is an subclass of QWebView), will be this QAction instance deleted on destruction of it parent(this), or should I take care of it?

    And one more question: what will be the behavior of deleteLater if the object got deleted before deleteLater slot will be executed? Is there any checks or maybe it gots disconnected from all signals on destruction?

  • Moderators

    Yes, QAction inherits QObject, it will be deleted just like every other QObject in parent-child hierarchy.

    As for deleteLater() - I don't know. You can always check :)

  • OK, thanks siedzio, I'll try it out... :)

Log in to reply