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

QML inline components cannot reference alias properties

    XMLWordPrintable

Details

    • Windows
    • 547f5761cb31600c9669ba205512fa0b6c7d36da (qt/qtdeclarative/dev)

    Description

      My test code:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          component MyCircle: Rectangle{
              id: rootMyCircle;
              property alias name: txtName.text
              property int age: 18
              height: 100; width: height; radius: height/2; anchors.centerIn: parent; color: "black";
              Component.onCompleted: console.log("Radius:",rootMyCircle.radius);
              Column {
                  anchors.centerIn: parent
                  Text { id: txtName; color: "white"; text: "Foo" }
                  Text { id: txtAge; color: "white"; text: age }
              }
          }
      
          MyCircle{
              // When either something or name is commented out: it works
              property string something: ""
              name: "Bar"
      
              age: 21
              radius: 5
          }
      }
      

      Compiling and running with Qt 5.15.2 windows produces error in runtime:

      qrc:/main.qml:26:9: Cannot assign to non-existent property "name"
      
      1. When the line with: property something is commented out it works
      2. When the line with: name: "Bar" is commented out it works

      So my conclusion is:
      Inner components with alias properties stop working when you define a new property in an instantiation of that inner component. Normal properties work perfectly fine though. Alias properties work fine as long as you don't define any new properties in an instantiation.

      Attachments

        Issue Links

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

          Activity

            People

              fabiankosmale Fabian Kosmale
              jeroen_o Jeroen Oomkes
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes