title: Qt4: How to call JavaScript functions in a page from C++ via QtWebkit?
body: <p>I'm trying to write a simple log viewer using Qt4's WebKit port/implementation. My HTML code looks like this:</p>
  
  <p><a href="http://pastie.org/613296" rel="nofollow noreferrer">http://pastie.org/613296</a></p>
  
  <p>More specifically, I'm trying to find out how to call the add_message() function which is defined in the <code>&lt;script&gt;</code> section in the HTML document from my C++ code.</p>
  
  <hr>
  
  <pre><code>// Doesn't work:
  QWebElement targetElement = chatView-&gt;page()-&gt;mainFrame()-&gt;findFirstElement("head").firstChild("script");
  
  // Function is not included, either...
  qDebug() &lt;&lt; targetElement.tagName() &lt;&lt; targetElement.functions();
  
  // The ultimate attempt in calling the function anyway:
  QVariant functionResult = targetElement.callFunction("add_message");
  </code></pre>