title: QtScript: Passing an array of objects to C++
body: <p>I want to pass an array of objects from my QtScript to C++ but I have not been able to figure out how to achieve this. As soon as I create an array, the elements inside it are converted to strings before I can access them.</p>
  
  <p>This is what I have been trying so far:</p>
  
  <pre><code>class myObject : public QObject, public QScriptable 
  {
      Q_OBJECT
  
  public Q_SLOTS:
      void test(QVariantList list);
  };
  
  void myObject::test(QVariantList list)
  {
      for (QVariantList::const_iterator it = list.begin(); it != list.end(); ++it) {
          QVariant element = *it;
  
          qDebug() &lt;&lt; element.typeName() &lt;&lt; element.toString();
  
          if (element.canConvert&lt;QVariantMap&gt;()) {
             // Not getting here
          }
      }
  }
  </code></pre>
  
  <p>The following script</p>
  
  <pre><code>myObject.test([{"foo": 1, "bar": 2}, {"baaz": 3, "baaaz": 4}]);
  </code></pre>
  
  <p>prints</p>
  
  <pre><code>"QString" "[object Object]"
  "QString" "[object Object]"
  </code></pre>
  
  <p>I am using Qt 4.6...</p>