在QT 5.10上未识别出新QT 5.10上的JavascriptWindowObjectCleared()的JavaS

what is the alternative of javaScriptWindowObjectCleared() on new qt 5.10 ?javaScriptWindowObjectCleared is not recognized on qt 5.10

本文关键字:QT JavascriptWindowObjectCleared JavaS 上的 识别      更新时间:2023-10-16

请帮助我要将webkit移植到WebEngine,但我有一些问题,我有一个信号JavascriptWindowObjectCleared((,这是New QT 5.10未识别的。在这种情况下,什么可以帮助我?

connect( this->page(), SIGNAL( javaScriptWindowObjectCleared() ), SLOT( OnPopulateJavaScriptObjec() ) );

以下代码sinppet可能会为您提供帮助。

    QWebEngineScript toBeInjectedjs;
    toBeInjectedjs.setName("qwebchannel.js"); 
    toBeInjectedjs.setInjectionPoint(QWebEngineScript::DocumentCreation); //important
    toBeInjectedjs.setRunsOnSubFrames(false);
    toBeInjectedjs.setWorldId(QWebEngineScript::MainWorld);
    toBeInjectedjs.setSourceCode(jsStr);  //jsStr is what your want to inject to page;
    scripts().insert(toBeInjectedjs); //scripts is a member function of QWebEnginePage.