title: How to build an API with QJSEngine?
body: <p>I am starting with Qt and one of my projects is using QJSEngine to evaluate javascript and I want to provide an entire API to the script, with classes and global functions.</p>
  
  <p>Right now my program provides only the ECMAScript default stuff (eval, encodeURI, parseInt, etc...), but I need to expose some custom classes to the code, like the browsers API (WebSocket class, Image class, document object). For example:</p>
  
  <pre class="lang-js prettyprint-override"><code>var obj = new CustomClass("", 0);
  var ret = obj.customClassMethod("[...]!");
  customFunction(ret);
  </code></pre>
  
  <p>I need to define the behavior of the classes in C++, it wouldn't help evaluate the classes definition and let the user code run.</p>