title: Calling C++ from JavaScript / HTML using GTK+ Webkit Webview (and Qt WebKit bridge)
body: <p>I am currently evaluating different approaches / solutions to call C++ functions from JavaScript code embedded in an HTML page. The application must be run on Ubuntu Server 12.04 LTS.</p>
  
  <p>I am not an expert in Linux based development. This is the first time I am trying to work on something to interface between JavaScript and C++ code.</p>
  
  <p>The C++ code basically resides in the .so files ( dynamic libraries) that would provide interface methods to access certain hardware and file system. The GUI needs to be in HTML and I am searching for different solutions that are possible that can call C++ from HTML. I searched and ended up deciding to try 2 approaches, both using the WebKit engine.</p>
  
  <p><strong>Approach 1: Using Qt 5.0.2 Webkit Bridge - the WebView control</strong><br>
  The GUI framework will be on Qt framework, the main application window will contain a webview control that would run an HTML code which in turn contains the JavaScript code.<br>
  The interface between Web page and C++ is done using the addToJavaScriptWindowObject() function. </p>
  
  <p>I created a sample application and tested this solution and it seems to works fine.</p>
  
  <p><strong>Approach 2: Using GTK+ WebKit WebView</strong><br>
  I downloaded and installed the GTK 3.0 library.<br>
  I got the webkitgtk 2.0.1 and have installed it.<br>
  I have created a test application with GTK without webkit, it works well.<br>
  I am trying to create a webkit webview control using GTK.  </p>
  
  <p>When trying my Approach 1 with Qt, there was quite a good set of documentation and samples to do what I wanted to. But after starting with Approach 2 using GTK+, I feel am moving slower comparitively. I personally feel that the documentation part is not that straight forward for the kind of application I am trying to develop.</p>
  
  <p><strong>Other Approaches:</strong><br>
  I also want to try to check if either using Applets (to call the .so files directly) or using the V8 JavaScript engine to interface between JavaScript and C++ are viable options(<a href="https://code.google.com/p/v8/" rel="nofollow">https://code.google.com/p/v8/</a>)</p>
  
  <p>I have tried the following resources:<br>
  <a href="http://webkitgtk.org/" rel="nofollow">http://webkitgtk.org/</a><br>
  <a href="http://www.webkit.org/" rel="nofollow">http://www.webkit.org/</a><br>
  <a href="https://live.gnome.org/WebKitGtk/ProgrammingGuide/Tutorial" rel="nofollow">https://live.gnome.org/WebKitGtk/ProgrammingGuide/Tutorial</a>  </p>
  
  <p>I want to know how exactly to do this interface part of calling a C++ functions (in .so files) when a button is clicked in a HTML web page containing JavaScript. What kind of signal am I supposed to look for. If I am using a WebkitWebview control, how do I map a button click to a c++ function?</p>
  
  <p>Can someone point me to the right direction?</p>
  
  <p>I would really appreciate your time and knowledge.</p>
  
  <p>Regards.</p>