Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Problem resetting a qquickwidget



  • Hi,
    I have a qml creating items dynamically with different functions, so I cannot track them. I am putting this qml inside a QQuickWidget and every time I want t reset it I was simply adding a new resource. Like this: ui->quickwidget->setSource(QUrl(QStringLiteral("main.qml"))). It was working fine, but now I have a problem that it appears to be deleting before qml could handle all signals. This is the error:
    Object 0x463b10 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!
    I would like to know if someone knows how to use deleteLater on qquickwidget or another way to reset my qml inside my quickwidget.
    Thank you all.



  • I solved it by using delete later. Just in case someone have the same problem, here is my solution code:

    ui->qml->rootObject()->deleteLater();

    connect(ui->qml->rootObject(), &QObject::destroyed, this, [=] {
    ui->qml->setSource(QUrl(QStringLiteral("main.qml")));

    emit apagou();
    

    });


Log in to reply