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

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

最佳答案

以下代码段可能会对您有所帮助。

    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.

关于c++ - 在新的qt 5.10上javaScriptWindowObjectCleared()的替代方法是什么?在qt 5.10上无法识别javaScriptWindowObjectCleared,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48686800/

10-09 13:12