Qt World Summit: Register Today!

Element ids vs context property names

  • Normally, using plain QML, I can create elements as children of other elements, give them ids, and refer to them using those ids.

    But now I want to instead add elements from C++, as context properties, and am a bit confused about how to use ids and context property names. Can I assign ids from C++, or is that not possible? If an element has an id, but is added as a context property, should I reference it in the QML through its id or its context property name?

    What seems to work is to not give it an id, and reference it through the context property name, but is that the best/proper/only way to do it?

Log in to reply