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

False positive warning about deferred properties

    XMLWordPrintable

Details

    Description

       This is maybe more a question than a bug: If you use something like this (used in a similar way in Tumbler.qml):

          Control {
              id: control
      
              contentItem: Repeater {
                  delegate: Item {
                      function foo() {
                          let ready = control.contentItem.areYouReady
                      }
                  }
      
                  readonly property bool areYouReady: true
              }
          }
      

      , you're getting 

      Warning: main.qml:31:53: Property "areYouReady" not found on type "QQuickItem"
                          let ready = control.contentItem.areYouReady
                                                          ^^^^^^^^^^^
      Error: main.qml:31:53: Could not compile function foo: Cannot load property areYouReady from QQuickItem of QQuickControl::contentItem with type QQuickItem.
                          let ready = control.contentItem.areYouReady
                                                          ^^^^^^^^^^^

      which sounds plausible.

      I'd tend to write it like this instead:

          Control {        
              contentItem: Repeater {
                  id:item
      
                  delegate: Item {
                      function foo() {
                          let ready = item.areYouReady
                      }
                  }
      
                  readonly property bool areYouReady: true
              }
          }
      

      , but that renders into

      Warning: main.qml:12:9: Cannot defer property assignment to "contentItem". Assigning an id to an object or one of its sub-objects bound to a deferred property will make the assignment immediate.
              contentItem: Repeater {
              ^^^^^^^^^^^

      . This are less warnings, and it seems like these

      Q_CLASSINFO("DeferredPropertyNames", xyz)

      are kind of internal, or the documentation is hidden somewhere.

       

      So - which version is better? Or is there one without any warnings?

       

      PS: the Jira "what you see is what you want to get" editor sucks

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            cajus Cajus Pollmeier
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes