How to manage the lifecycle of a lambda function in QWebEnginePage::runJavaScript method

       QWebEngineView webEngineView;
       webEngineView->page()->runJavaScript("...", [this](const QVariant &v)

    The problem is that sometimes 'this' is destructed when the lambda function is called. Suppose 'this' is derived from QObject, how can we ensure that 'this' is valid when the lambda function is called? For example when using QObject::connect when we specify a context for lambd function, and when the destination object is destroyed the connection is disconnected automatically.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.