August 12, 2010

dmcr dmcr
Lab Rat
173 posts

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

 

Hello,

and if so, how ?

;=)

 Signature 

dmcr

7 replies

August 12, 2010

aalpert aalpert
Lab Rat
44 posts

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.

August 16, 2010

dmcr dmcr
Lab Rat
173 posts

Thank you for your quick answer.

 Signature 

dmcr

June 3, 2011

Vijay Bhaska Reddy Vijay Bhaska Reddy
Lab Rat
399 posts

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

Will this help you?

September 6, 2011

Kunal Parmar Kunal Parmar
Lab Rat
18 posts

I used following code in one of my project.

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

September 7, 2011

Alicemirror Alicemirror
Lab Rat
825 posts

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.

 Signature 

Enrico Miglino (aka Alicemirror)
Tech Consulting
Islas Baleares, Ibiza (Spain)
http://www.contesti.eu

October 13, 2011

frankiefrank frankiefrank
Hobby Entomologist
229 posts

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.

 Signature 

“Roads? Where we’re going, we don’t need roads.”

October 13, 2011

dmcr dmcr
Lab Rat
173 posts

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 ;)

 Signature 

dmcr

 
  ‹‹ QML/3D saw this new video on youtube      How to clear qmlviewer cache and cookies of WebView? ››

You must log in to post a reply. Not a member yet? Register here!