title: How to create and use C++ objects in QML Javascript
body: <p>My app uses both c++ and QML.</p>
  
  <p>I've defined several objects in C++ part to access SQL etc.</p>
  
  <p>It looks like:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class MyObject : public QObject
  {
      Q_OBJECT
  public:
      MyObject(QObject *parent = 0);
      Q_INVOKABLE void someFunction(const QString &amp;query);
  };
  
  qmlRegisterType&lt;MyObject&gt;("xxx.xxx", 1, 0, "MyObject");
  </code></pre>
  
  <p>Ideally, I need to use these objects only in Javascript not in QML.</p>
  
  <p>I tried a lot of examples and read all the documentation but still can't solve my problem.</p>
  
  <p>So my questions:</p>
  
  <ul>
  <li>How can I instance in Javascript an object defined in C++? I tried <code>var obj = Qt.createComponent("MyObject");</code> but it seems not works. Is it possible to define new object in normal JS style - <code>var obj = new MyObject;</code>?</li>
  <li>How can I access this created object in javascript? I tried obj.someFunction("xxx") but got some error - <code>TypeError: Property 'someFunction' of object QQmlComponent(0x3605f5c0) is not a function.</code> What I do wrong here? My object derived from QObject, not from QQmlComponent.</li>
  </ul>