Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Getting sender (QWebView) of javaScriptWindowObjectCleared signal

    Qt WebKit
    javascript qweb qwebview sender
    1
    2
    1118
    Loading More Posts
    • 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.
    • McLion
      McLion last edited by

      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 Reply Quote 0
      • McLion
        McLion last edited by

        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 Reply Quote 0
        • First post
          Last post