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

Repeater delegates have no parent when their Component.onCompleted is called

    XMLWordPrintable

Details

    Description

      Run the code below. Note that the three blue rectangles print
      TypeError: Cannot call method 'toString' of null in their
      Component.onCompleted while the green and yellow rects print
      the name of their parents as expected.

      import QtQuick 2.0
      Rectangle {
          width: 400; height: 600
      
          Row {
              anchors.centerIn: parent
              spacing: 3
      
              Rectangle {
                  width: 50; height: 50; color: "green"
                  Component.onCompleted: {
                      print(parent.toString());
                  }
              }
      
              Loader {
                  sourceComponent: Rectangle {
                      width: 50; height: 50; color: "yellow"
                      Component.onCompleted: {
                          print(parent.toString());
                      }
                  }
              }
      
              Repeater {
                  model: 3
                  delegate: Rectangle {
                      width: 50; height: 50; color: "blue"
                      Component.onCompleted: {
                          print(parent.toString());
                      }
                  }
              }
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            martjone Martin Jones (closed Nokia identity) (Inactive)
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes