Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-65261

QML Repeater : where are the objects?

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.10.0, 6.4.2, 6.5.0 Beta3
    • None

    Description

      Given the following code:

       

      import QtQuick 2.5
      
      Item {
          Repeater {
              model: 3
              Item {
                  objectName: "Root"
                  Rectangle {
                      objectName: "Rect"
                      Repeater {
                          model: 5
                          Rectangle {
                              objectName: "Child"
                          }
                      }
                  }
              }
          }
      }
      

      when dumping the object tree of the root item I get this:

       

      QQuickItem(0x55da76bea800, parent=0x0, geometry=0,0 0x0)
       QQuickRepeater(0x55da76c1b270)
        QQmlComponent(0x55da76c1c030)
       QQuickItem(0x55da76c1cb70, name="Root", parent=0x55da76bea800, geometry=0,0 0x0)
        QQuickRectangle(0x55da76c43760, name = "Rect")
         QQuickRepeater(0x55da76c43a30, parent=0x55da76c43760, geometry=0,0 0x0)
          QQmlComponent(0x55da76c44570)
       QQuickItem(0x55da76c471f0, name="Root", parent=0x55da76bea800, geometry=0,0 0x0)
        QQuickRectangle(0x55da76c47430, name = "Rect")
         QQuickRepeater(0x55da76c47700, parent=0x55da76c47430, geometry=0,0 0x0)
          QQmlComponent(0x55da76c48050)
       QQuickItem(0x55da76c4ab90, name="Root", parent=0x55da76bea800, geometry=0,0 0x0)
        QQuickRectangle(0x55da76c4ada0, name = "Rect")
         QQuickRepeater(0x55da76c4b010, parent=0x55da76c4ada0, geometry=0,0 0x0)
          QQmlComponent(0x55da76c4b9b0)

       

      No matter how hard I wait ad run qApp->processEvents(), I never get my child objects in the object / item tree.

       

      My dump code is the following:

      static int n = 0;
      void dumpTree(QQuickItem* root);
      void dumpTree(QObject* root)
      {
        QString sep(n, ' ');
        qDebug() << qPrintable(sep) << root;
        n++;
        for(auto cld : root->children())
        {
          if(auto item = qobject_cast<QQuickItem*>(cld))
          {
            dumpTree(item);
          }
          else
          {
            dumpTree(cld);
          }
        }
        n--;
      }
      void dumpTree(QQuickItem* root)
      {
        QString sep(n, ' ');
        qDebug() << qPrintable(sep) << root;
        n++;
        std::set<QObject*> dumped;
        for(auto cld : root->children())
        {
          dumpTree(cld);
          dumped.insert(cld);
        }
        for(auto cld : root->childItems())
        {
          if(dumped.find((QObject*)cld) == dumped.end())
            dumpTree(cld);
        }
        n--;

      And the main:

      QCoreApplication app(argc, argv);
      ossia::context context;
      QQmlEngine engine;
      
      QFile f("TestQmlRepeater.qml");
      f.open(QIODevice::ReadOnly);
      QQmlComponent component(&engine);
      component.setData(f.readAll(), QUrl());
      auto item = (QQuickItem*) component.create();
      for(int i = 0; i < 100; i++)
        qApp->processEvents();
      dumpTree(item);
      

      Thanks!

       

       

      Attachments

        1. main.cpp
          1 kB
        2. main.qml
          0.8 kB
        3. QTBUG-65261.pro
          0.0 kB

        Issue Links

          For Gerrit Dashboard: QTBUG-65261
          # Subject Branch Project Status CR V

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              jcelerier Jean-Michaël Celerier
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change