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

Component components cannot have properties

    XMLWordPrintable

Details

    Description

      Although this is parsed by QML:

      MyDelegate.qml
      import Qt 4.6
      Component {
          property alias text: t.text
          Text { id: t; text: "hello" }
      }
      

      it cannot be used:

      import Qt 4.6
      GridView {
          MyDelegate {
              id: d
              text: "goodbye"
          }
          delegate: d
          model: 3
      }
      

      it gives error:

      bug.qml:6:9: Cannot assign to non-existent property "text"
                   text: "goodbye"
      

      The desired result can be achieved:

      MyDelegate.qml
      import Qt 4.6
      Item {
          property alias text: t.text
          Text { id: t; text: "hello" }
      }
      
      import Qt 4.6
      GridView {
          Component {
              id: d
              MyDelegate {
                  text: "goodbye"
              }
          }
          delegate: d
          model: 3
      }
      

      Should either work, or Component should not be allowed as top level of QML file, or Components should not be allowed to have new/aliased properties.

      Attachments

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

        Activity

          People

            aakenned Aaron Kennedy
            wallison Warwick Allison (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes