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
Forum Updated to NodeBB v4.3 + New Features

Getting sender (QWebView) of javaScriptWindowObjectCleared signal

Scheduled Pinned Locked Moved Solved Qt WebKit
javascript qwebqwebviewsender
2 Posts 1 Posters 1.5k 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.
  • McLionM Offline
    McLionM Offline
    McLion
    wrote on 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
    • McLionM Offline
      McLionM Offline
      McLion
      wrote on 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

      • Login

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