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

QML inline components cannot reference inner objects

    XMLWordPrintable

Details

    • Windows
    • b4d36a05be9f34976c1a1b5ea60ce03c4ab59a25 (qt/qtdeclarative/dev) ec1fc3aaa78c2c6a8ed660f26bc2c26b7d0c10bb (qt/qtdeclarative/5.15)

    Description

      My test code:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
          width: 200
          height: 100
          visible: true
          title: "Inline component test"
      
          component TestComponent : Item {
              property alias text: innerText.text
      
              width: innerText.implicitWidth
              height: innerText.implicitHeight
      
              Text {
                  id: innerText
              }
          }
      
          TestComponent {
              text: "Something"
          }
      }
      

      Compiling and running with Qt 5.15 RC2 produces error in runtime:

      qrc:/main.qml:25:9: Cannot assign to non-existent property "text"
      

      That's on attempt to set `text` in `TestComponent` instantiation. Removing the usage of `text` property, leaving only `width` and `height` bindings to `innerText`, leads to another errors:

      qrc:/main.qml:15: ReferenceError: innerText is not defined
      qrc:/main.qml:14: ReferenceError: innerText is not defined
      

      Attachments

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

        Activity

          People

            fabiankosmale Fabian Kosmale
            vladimmi Vladimir Marchevsky
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes