Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Closed] Is it possible to create a dynamic QML instance of an element and give it an id ?

[Closed] Is it possible to create a dynamic QML instance of an element and give it an id ?

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 6 Posters 6.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dmcr
    wrote on 12 Aug 2010, 08:40 last edited by
    #1

    Hello,

    and if so, how ?

    ;=)

    dmcr

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aalpert
      wrote on 12 Aug 2010, 09:39 last edited by
      #2

      No. If you dynamically create QML elements you have to manage them dynamically, via variables.

      You can assign them to a property (such as children) of an element with an id, if you're having trouble finding them again after creation.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dmcr
        wrote on 16 Aug 2010, 06:38 last edited by
        #3

        Thank you for your quick answer.

        dmcr

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thisisbhaskar
          wrote on 3 Jun 2011, 11:00 last edited by
          #4

          http://doc.qt.nokia.com/main-snapshot/qml-component.html#createObject-method

          Will this help you?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kunal_the_one
            wrote on 6 Sept 2011, 04:37 last edited by
            #5

            I used following code in one of my project.

            http://kunalmaemo.blogspot.com/2011/04/creating-qml-element-dynamically-on.html

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Alicemirror
              wrote on 7 Sept 2011, 12:41 last edited by
              #6

              To work dynamically and manage the elements with id and properties, you can use them with the Loader elements. Loaders can be created and destroyed as you need at runtime.

              Enrico Miglino (aka Alicemirror)
              Balearic Dynamics
              Islas Baleares, Ibiza (Spain)
              www.balearicdynamics.com

              1 Reply Last reply
              0
              • F Offline
                F Offline
                frankiefrank
                wrote on 13 Oct 2011, 10:05 last edited by
                #7

                I was wondering the same thing. You can assign your own "id" to the objectName property:
                http://doc.qt.nokia.com/4.7-snapshot/qml-qtobject.html#objectName-prop

                Then you can write a simple javascript loop if you need to find your object by name, by iterating through its parent's children.

                "Roads? Where we're going, we don't need roads."

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dmcr
                  wrote on 13 Oct 2011, 11:59 last edited by
                  #8

                  Yes, but the fact is you have no protections of having two differents objects with the same objectName, which could be troubleSome.

                  After some work in QML, i find it not that much annoying, since the most important things are done in C++ side, except displaying, oeuf corse.

                  So....

                  This is perhaps the time to close this post ;)

                  dmcr

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved