Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Inserting QWebEngineScript on next page run time.



  • I want that whenever a button on web-page (let's say a.html) get clicked my slot in core class i.e. (QWebChannel->registerObject("core", core);) gets called and it working very well only when I start calling WebEngineView->load(a.html).
    But if I am redirecting from B.html to A.html then slot not gets called. Fallowing is my code snippet:

    QWebEngineView *webEngine = new QWebEngineView(this);
    
    QWebEngineProfile *profile = new QWebEngineProfile("MyWebChannelProfile", webEngine);
    
    QWebEngineScript script2;
        script2.setSourceCode(createJsStringAfterLoad()); //here in this function I am creating my java script code which will call core class slot
        script2.setName("qwebchannel2.js");
        script2.setWorldId(QWebEngineScript::MainWorld);
        script2.setInjectionPoint(QWebEngineScript::DocumentReady);
        script2.setRunsOnSubFrames(true);
        profile->scripts()->insert(script2);
    
    QWebEnginePage *myPage = new QWebEnginePage(profile, m_webEngine);
        webEngine->setPage(myPage);
    
        QWebChannel *channel = new QWebChannel(myPage);
        webEngine->page()->setWebChannel(channel);
    
        Core *core = new Core(this);   //in this class my slot is present which I want to get called
        channel->registerObject("core", core);
     m_webEngine->load(a.html);
    

    Please let me know how to insert the QWebEngineScript on next redirected page without knowing its url.