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

QQmlComponent seems unable to create a component that has a required alias

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.8
    • 6.7
    • QML: Tooling
    • None

    Description

      `QQmlComponent` seems unable to create a component that has a required alias.

      Given:

      Item {
        id: self
        property int foo
        property alias aliasToFoo: self.foo
        required aliasToFoo
      }
      

      `aliasToFoo` will appear as a required property and will thus produce an error unless it is initialized.

      Nonetheless, trying to set an initial value for it will not actually mark the alias as being set, in turn failing to create the object due to the an uninitialized required property.

      For example, creating the component as follows:

      component.createWithInitialProperties({{"aliasToFoo", 10}})
      

      Will still produce an error:

      Required property aliasToFoo was not initialized
      

      Setting a binding from the QML side will actually work, for example:

      aliasToFoo: 42
      

      Will ensure that no error is present, suggesting that the issue might be related to the way `QQmlComponent::createWithInitialProperties` treats initializing aliases.

      Attachments

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

        Activity

          People

            diseraluca Luca Di Sera
            diseraluca Luca Di Sera
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes