新qt 5.10上javaScriptWindowObjectCleared()的替代方法是什么?在qt 5.10上无法识别javaScriptWindowObjectCleared

时间:2018-02-08 13:36:03

标签: c++ qt qt5

请帮助我想将webkit移植到WebEngine但是我遇到了一些问题,我有一个信号javaScriptWindowObjectCleared(),新qt 5.10无法识别。在这种情况下,有什么可以帮到我?

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

1 个答案:

答案 0 :(得分:0)

以下代码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.