Important: Please read the Qt Code of Conduct -

Use an instance of a Component on two Pages

  • Is it possible to use the same instance of a displayable Component like a Rectangle in two different places. For example, on two different Pages on a PageStackWindow? If so, what's the syntax?

  • No, but you can reparent an item when needed.

  • Can I do that by assignment

    component_id.parent = new_parent_id

    or must I use a State change and the ParentChange element?

  • I tried it with interesting results.

    Reparenting by assignment worked!

    Reparenting by changing state and using a ParentChange did not work. The Component did not appear at all. I tried this with a simple red rectangle and this, too, failed. Is there something magical about PageStackWindow and Page that prevents this from working?

    Thank you for helping me, Andre.

  • Looks like a good optimization at-least in my case. We are facing performance problems when qml items are created dynamically. I will do some r&d to see if we can recycle and use the created items. Please do share your updates about this.

Log in to reply