Qt World Summit: Submit your Presentation

Difference between Repeater and Instantiator

  • What is the difference between Repeater and Instantiator?

    For Repeater it says:

    Instantiates a number of Item-based components using a provided model

    For Instantiator it says:

    A Instantiator can be used to control the dynamic creation of objects, or to dynamically create multiple objects from a template.

    But ins't that the same?

    Is the Instantiator even ever used nowadays. I couldn't find good examples.

  • Qt Champions 2018

    Repeater only work with Item delegates and it parents the delegate it creates to the Repeater's parent item.
    Instantiator work with every objects.

  • @GrecKo

    So that means with Instantiator I have to parent the items myself after?

  • Both types have signals that get called when items/objects are created. You can use these signals to insert/remove the items/objects. I use Instantiators when I want precise control of parenting via a function that I call to determine the parenting. I also use Instantiators to create non-Item objects. For instance you can create Emitters for particles on the fly this way. I have found Repeaters useful for creating MenuItems for Menus for things like file history.

  • @fcarney Thanks for the explanation. I wasn't thinking about stuff like Emitter to create dynamically.

    So the main differences are:


    Can only create Item based elements dynamically

    Parenting happens automatically for created elements.


    Can create "all" Elements dynamically.

    Created elements have to be parented manually.

    Which library do you have to import to use Instantiator? I tried to use import QtQml 2.2 like the docs say but than it says "Unknown component".

  • @sandro4912 said in Difference between Repeater and Instantiator:

    Which library do you have to import to use Instantiator?

    At the top of page it says the import. Also, searching "qml instantiator" will find that page.

Log in to reply