Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-24493

list<Text> property takes Qobject def in initializer but not when called

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • None
    • Qt Creator 4.13.3
    • Quick / QML Support
    • None

      I read further into property definitions.
      I found a list type definition. So I am trying to understand it.

      I created an Item element (called it Glossary.qml).
      It contained the following definition

      property list<Text> aword: [
      Text

      { text: "testing"}

      ,
      Text

      { text: "this is word 2"}

      ]

      Then in the main qml element I created a call to
      Glossary

      { id: ac}

      Component.onCompleted
      {
      ac.aword.push( Text

      { text: "third word"}

      );
      console.log( ac.aword[0].text);
      console.log( ac.aword[1].text);
      console.log( ac.aword[2].text);
      }
      The push operation would not let me do this, my guess it wanted an "id" value.
      When I moved the Text definition argument out of the push function and gave it an "id"
      and placed that id in its place of the object definition everything worked.

      Now my question is: If the element is created dynamically how to I added to
      to the glossary property since it has no ID?

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

            qtqmlteam Qt Qml Team User
            lawrence.emke Lawrence Emke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes