title: How to pass QVector<Custom_Q_GADGET> to QML?
body: <p>I have QObject class with 2 properties:</p>
  
  <pre><code>class Foo : public QObject {
  Q_OBJECT
      Q_PROPERTY(QVector&lt;Namespace1::Namespace2::Item&gt; items READ getItemVector)
      Q_PROPERTY(QVector&lt;QString&gt; tests READ getTestVector)
      ...
  }
  
  QVector&lt;Namespace1::Namespace2::Item&gt; Foo::getItemVector() const
  {
      return _item_vector;
  }
  
  QVector&lt;QString&gt; Foo::getTestVector() const
  {
      return _test_vector;
  }
  </code></pre>
  
  <p>Everything is ok with <code>QVector</code> of <code>QString</code>s in the QML, but I was not able to pass <code>QVector</code> of <code>Namespace1::Namespace2::Item</code>s. </p>
  
  <p>Output to QML console gives me:
  <code>QVariant(​QVector&lt;Namespace1::Namespace2:​Item&gt;)​</code> for console.log(foo.items)
  and 
  <code>length = undefined</code> for console.log(foo.items.length)</p>
  
  <p>What I have found out from the Qt documentation:</p>
  
  <blockquote>
    <p>These sequence types are implemented directly in terms of the underlying C++ sequence. There are two ways in which such sequences can be exposed to QML: as a Q_PROPERTY of the given sequence type; or as the return type of a Q_INVOKABLE method.</p>
  </blockquote>
  
  <p>...</p>
  
  <blockquote>
    <p>In particular, QML currently supports: ... QList&lt; QString >... and all registered QList, QVector, QQueue, QStack, QSet, QLinkedList, std::list, std::vector that contain a type marked with Q_DECLARE_METATYPE.</p>
  </blockquote>
  
  <p>As I understand, everything boils down simply to:</p>
  
  <pre><code>Q_DECLARE_METATYPE(Namespace1::Namespace2::Item)
  </code></pre>
  
  <p>Besides this:</p>
  
  <blockquote>
    <p>Some types are registered automatically and do not need this macro: Pointers to classes derived from QObject, QList&lt; T >, <strong>QVector&lt; T ></strong>, QQueue&lt; T >, QStack&lt; T >, QSet&lt; T > or QLinkedList where T is a registered meta type</p>
  </blockquote>
  
  <p>However, I also tried to declare metatype(without luck, obviously):</p>
  
  <pre><code>Q_DECLARE_METATYPE(QVector&lt;Namespace1::Namespace2::Item&gt;)
  </code></pre>
  
  <p>and also tried to register metatypes(without any luck as well):</p>
  
  <pre><code>qRegisterMetaType&lt;Namespace1::Namespace2::Item&gt;("Namespace1::Namespace2::Item");
  qRegisterMetaType&lt;QVector&lt;Namespace1::Namespace2::Item&gt;&gt;("QVector&lt;Namespace1::Namespace2::Item&gt;");
  </code></pre>
  
  <p>The <code>Item</code> by itself is a <code>Q_GADGET</code>:</p>
  
  <pre><code>namespace Namespace1 { namespace Namespace2 {
      class Item
      {
      Q_GADGET
          Q_PROPERTY(QString name READ getName CONSTANT)
  
      public:
          Item();
          Item(const QString&amp; name);
          Item(const Item&amp; origin);
          Item(Item&amp;&amp; origin);
          ~Item();
  
      private:
          QString _name;
  
      public:
          Item&amp; operator=(const Item&amp; rhs);
          Item&amp; operator=(Item&amp;&amp; rhs);
  
      friend QDataStream&amp; operator&lt;&lt;(QDataStream&amp; out, const Item&amp; item);
      friend QDataStream&amp; operator&gt;&gt;(QDataStream&amp; in, Item&amp; item);
      friend QDebug operator&lt;&lt;(QDebug debug, const Item&amp; item);
      }
  } }
  </code></pre>
  
  <p>What am I missing?
  Thank you!</p>