Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Getting sender (QWebView) of javaScriptWindowObjectCleared signal

Getting sender (QWebView) of javaScriptWindowObjectCleared signal

Scheduled Pinned Locked Moved Solved Qt WebKit
javascript qwebqwebviewsender
2 Posts 1 Posters 1.4k Views
  • 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.
  • M Offline
    M Offline
    McLion
    wrote on 6 Apr 2016, 11:32 last edited by
    #1

    Hi
    I had a single QWebView. Upon the creation I do

    connect(webGUI->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
    

    to be able to call a native function from JavaScript.
    The slot:

    void QTGUI_MainWindow::populateJavaScriptWindowObject()
    {
      webGUI->page()->mainFrame()->addToJavaScriptWindowObject("NativeBridge", this);
    }
    

    When I was having only one WebView that worked perfectly.

    I now create additional QWebViews as needed at run-time.
    The connect upon their creation stays the same.
    However, the slot to re-add the object needs to know the QWebView the JavaScript signal did come from.
    I actually have a map where I store all the QWebView * for every one created. What I dont have is the sender from which the javaScriptWindowObjectCleared has been sent.
    How can I get that?
    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      McLion
      wrote on 6 Apr 2016, 14:55 last edited by
      #2

      Got it solved :-)

        QWebFrame * webGUIframe = qobject_cast<QWebFrame *>(sender());
        QWebView * webGUI = (QWebView*)(webGUIframe->parent())->parent();
        webGUI->page()->mainFrame()->addToJavaScriptWindowObject("NativeBridge", this);
      
      1 Reply Last reply
      0

      2/2

      6 Apr 2016, 14:55

      • Login

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