Important: Please read the Qt Code of Conduct -

Changing view's model crashes at some point

  • Lets say I have a bunch of tabs and on tab index changed I change the model of a TreeView for the corresponding on in a map I have made in C++.

    What I have described works great, the issue is that after a little time switching around the tabs it crashes with this error:

    Thank you for your help.

  • Nevermind I found a solution:

    QQmlApplicationEngine::setObjectOwnership(MY_OBJECT*, QQmlApplicationEngine::CppOwnership);

    It's important to set this whenever returning a pointer in a Q_INVOKABLE function or else it might get garbage collected apparently.