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

qmlcompiler: Implement ability to deal with reparenting

    XMLWordPrintable

Details

    Description

      We need to add the ability for qmlcompiler to handle dynamic reparenting. This can probably be done by adding the necessary information to qmltypes.

      Example where not handling dynamic reparenting (but instead using the document parent) leads to us not issuing a warning, even though we should:

      import QtQuick 2.15
      
      ListView {
        id: lv
        model: 1
        delegate: Text {
          text: parent.keyNavigationEnabled // this does not work
          // text: lv.keyNavigationEnabled // <-- this works
        }
      }
      

      The reverse case can be handled via an as cast (if the contentItem has a named type), but that's still unfortunate:

      ListView {
          contentItem: Rectangle {
              color: "red"
          }
          delegate: Text {
              color: NotQt.complimentaryColor((parent as Rectangle).color) // this as cast shouldn't be needed
          }
      }
      

      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
            max.goldstein Maximilian Goldstein
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes