Qt World Summit: Register Today!

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:


    connect(ui->qml->rootObject(), &QObject::destroyed, this, [=] {

    emit apagou();


Log in to reply