[Interest] Reasons why deleteLater() might not work

Michael Jackson mike.jackson at bluequartz.net
Sun Apr 3 20:23:01 CEST 2022


So buried deep in the code base (which was being reused from another project) was an event filter that was specifically looking for deleteLater() and then swallowing it up. I need to figure out why in the other project we were doing that. I knew it was "user error", just needed some help getting me point in the right direction to look for issues.

We would like to clean up children items when they are removed from the UI. They are generated on the fly and may contain heavier data that one would want just laying around. Now that deleteLater() is working, in fact we just remove the single parent, call deleteLater() on it and everything finally gets deleted as it should.

Thanks everybody for the help.

--
Mike Jackson 

On 4/3/22, 4:25 AM, "Interest on behalf of Nikos Chantziaras" <interest-bounces at qt-project.org on behalf of realnc at gmail.com> wrote:

    On 01/04/2022 16:17, Michael Jackson wrote:
    > I have a bit of code where in I am removing a QWidget from the UI and it needs to be truly cleaned up as its parent QObject is also being cleaned up. I thought I did the appropriate:
    > 
    > layout->removeWidget(widget);
    > widget->setParent(nullptr);
    > widget->deleteLater();

    Why not simply delete the parent, which will then delete all its 
    children immediately?

    Also, I don't even remember a single case where I ever needed deleteLater().

    _______________________________________________
    Interest mailing list
    Interest at qt-project.org
    https://lists.qt-project.org/listinfo/interest




More information about the Interest mailing list