title: Expose QList<QObject *> hierarchy to QML
body: <p>I'm currently in the situation, that I have a QList with MyClass also including a list QList.</p>
  
  <p>To display this list-hierarchy I want to provide a Repeater within a ListView.</p>
  
  <p>I tried this with a QStringList and it works fine (see uncommented lines below). When I try to do this with my QList I cannot access the name-property of MySubClass. Instead the name-property of MyClass is shown.</p>
  
  <p>WRONG output:</p>
  
  <pre><code>Object 1
  Object 1
  Object 1
  Object 2
  </code></pre>
  
  <p>Correct output should be:</p>
  
  <pre><code>Object 1
  SubObject 1
  SubObject 2
  Object 2
  </code></pre>
  
  <p><strong>EDIT: 08.12.2014</strong>
  I found out, why the sublist did not work. I just had to replace one line in the delegate of the sub-ListView (name -> modelData.name).</p>
  
  <p>Here's my code:</p>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include &lt;QGuiApplication&gt;
  #include &lt;QQmlApplicationEngine&gt;
  #include &lt;QQmlContext&gt;
  #include &lt;QList&gt;
  #include &lt;QDebug&gt;
  
  #include "myclass.h"
  
  int main(int argc, char *argv[])
  {
      QGuiApplication app(argc, argv);
  
      /* create simple stringlist */
      QStringList dataList;
      dataList &lt;&lt; "Data 1"
           &lt;&lt; "Data 2"
           &lt;&lt; "Data 3";
  
      /* create more complex QObject List */
      MySubClass *mySubObject = NULL;
      QList&lt;QObject *&gt; mySubList;
  
      mySubObject = new MySubClass;
      mySubObject-&gt;setName("SubObject 1");
      mySubList.append(mySubObject);
  
      mySubObject = new MySubClass;
      mySubObject-&gt;setName("SubObject 2");
      mySubList.append(mySubObject);
  
      /* create object list */
      MyClass *myObject = NULL;
      QList&lt;QObject *&gt; myList;
  
      myObject = new MyClass;
      myObject-&gt;setName("Object 1");
      myObject-&gt;setDataList(dataList);
      myObject-&gt;setObjectList(mySubList);
      myList.append(myObject);
  
      myObject = new MyClass;
      myObject-&gt;setName("Object 2");
      myObject-&gt;setDataList(dataList);
      myList.append(myObject);
  
      qDebug () &lt;&lt; myList.size();
  
      myObject = NULL;
  
      /* start engine and expose object list */
      QQmlApplicationEngine engine;
  
      QQmlContext *myContext = engine.rootContext();
      myContext-&gt;setContextProperty("myObjectList", QVariant::fromValue(myList));
  
      engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
  
      return app.exec();
  }
  </code></pre>
  
  <p><strong>MyClass.h</strong></p>
  
  <pre><code>#ifndef MYCLASS_H
  #define MYCLASS_H
  
  #include &lt;QObject&gt;
  #include &lt;QStringList&gt;
  
  #include "mysubclass.h"
  
  class MyClass : public QObject
  {
      Q_OBJECT
      Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
      Q_PROPERTY (QStringList dataList READ dataList WRITE setDataList NOTIFY dataListChanged)
      Q_PROPERTY (QList&lt;QObject *&gt; objectList READ objectList WRITE setObjectList NOTIFY objectListChanged)
  public:
      inline MyClass(QObject *parent = 0) : QObject(parent) {}
      inline ~MyClass() {}
  
      QString name() const
      {
          return m_name;
      }
  
      QStringList dataList() const
      {
          return m_dataList;
      }
  
      QList&lt;QObject *&gt; objectList() const
      {
          return m_objectList;
      }
  
  public slots:
      void setName(QString arg)
      {
          if (m_name != arg) {
              m_name = arg;
              emit nameChanged(arg);
          }
      }
  
      void setDataList(QStringList arg)
      {
          if (m_dataList != arg) {
              m_dataList = arg;
              emit dataListChanged(arg);
          }
      }
  
      void setObjectList(QList&lt;QObject *&gt; arg)
      {
          if (m_objectList != arg) {
              m_objectList = arg;
              emit objectListChanged(arg);
          }
      }
  
  signals:
      void nameChanged(QString arg);
      void dataListChanged(QStringList arg);
  
      void objectListChanged(QList&lt;QObject *&gt; arg);
  
  private:
      QString m_name;
      QStringList m_dataList;
  
      QList&lt;QObject *&gt; m_objectList;
  };
  
  #endif // MYCLASS_H
  </code></pre>
  
  <p><strong>MySubClass.h</strong></p>
  
  <pre><code>#ifndef MYSUBCLASS_H
  #define MYSUBCLASS_H
  
  #include &lt;QObject&gt;
  #include &lt;QString&gt;
  
  class MySubClass : public QObject
  {
      Q_OBJECT
      Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
  
  public:
      inline MySubClass(QObject *parent = 0) : QObject(parent) {}
      inline ~MySubClass() {}
  
      QString name() const
      {
          return m_name;
      }
  public slots:
      void setName(QString arg)
      {
          if (m_name != arg) {
              m_name = arg;
              emit nameChanged(arg);
          }
      }
  signals:
      void nameChanged(QString arg);
  
  private:
      QString m_name;
  };
  
  #endif // MYSUBCLASS_H
  </code></pre>
  
  <p><strong>main.qml</strong></p>
  
  <pre><code>import QtQuick 2.2
  import QtQuick.Window 2.1
  
  Window {
      visible: true
      width: 360
      height: 360
  
      ListView  {
          id: view
          anchors.fill: parent
  
          model: myObjectList
  
          delegate: Item {
              width: parent.width
              height: col.height
              Column {
                  id: col
                  Text {
                      id: nameLabel
                      text: name
                  }
  
                  Repeater {
                      id: dataView
  //                    model: dataList
                      model: objectList
                      delegate: Text {
                          id: dataLabel
  //                        text: modelData
                          // text: name
                            /* Here's the fix!!! (dunno why, but it works) */
                            text: modelData.name
                      }
                  }
              }
          }
      }
  }
  </code></pre>