⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

destroyed while one of its QML signal handlers is in progress

  • I have a StackView in my project and sometimes i push a new page or pop a page from that ... and it is working normally and fine.

    but sometimes in some pages i call a non return function (void) a from a c++ class (i defined it in public slots part in header) ... when i poping that page, if the function is not finished yet whole of the app crashes and write this error in output console:

    destroyed while one of its QML signal handlers is in progress.
    Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop.
    This behavior is NOT supported!
    qrc:/Posts.qml:387: function() { [native code] }

    What's wrong with me?

  • finaly I fixed it myself:
    we can call function from another function with


    In this way, qml item no longer waits for the cpp function to end,
    for example:

    void MyClass::functionA(QString url,QString allParams)
        QMetaObject::invokeMethod( this, "functionAـreal",Qt::QueuedConnection, Q_ARG( QString, url ), Q_ARG( QString, allParams ));
    void MyClass::functionAـreal(QString url,QString allParams)
    .............. Things that take longer

  • Had the same issue, and used your solution to solve the problem. Thanks.

    One thing that worth mentioning here is that if you use QMetaObject::invokeMethod to run a method, you should declare that method as a slot in your class definition for it to work.

  • Worked for me perfectly too.

    @lotfollah thanks for mentioning that the function that should be used with QMetaObject should be a slot.

Log in to reply