Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Inserting QWebEngineScript on next page run time.
Forum Updated to NodeBB v4.3 + New Features

Inserting QWebEngineScript on next page run time.

Scheduled Pinned Locked Moved Unsolved QtWebEngine
webengine qt5webengineview
1 Posts 1 Posters 642 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zee_07
    wrote on 18 Oct 2018, 13:27 last edited by
    #1

    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.

    Thanks and Kind Regards,
    Zee_07

    1 Reply Last reply
    0

    1/1

    18 Oct 2018, 13:27

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved