The QML types Component
and Instantiator
appear to do similar things; create QML objects on demand, as opposed to when parsing their definitions. So what's the difference? Why would I want to use one over the other?
Asked
Active
Viewed 2,641 times
1 Answers
4
An Instantiator
creates instances of the given Component
- one for each model-entry given in model
. It's similar to the Repeater.
A Component
is a Class. A Instantiator
is sort of a Factory for the given Component.

Mitch
- 23,716
- 9
- 83
- 122

Florian Schmidt
- 369
- 3
- 13
-
But can't I just create instances of a `Component` without an `Instantiator`? – JesseTG Aug 08 '16 at 17:57
-
There are multiple Possibilities, choose which one fits best for you: You can use a [`Loader`](http://doc.qt.io/qt-5/qml-qtquick-loader.html) for a single Instance, a [`Repeater'](http://doc.qt.io/qt-4.8/qml-repeater.html) for multiple instances. Since QtQml2.2 there is also the [`Instantiator'](http://doc.qt.io/qt-5/qml-qtqml-instantiator.html) which is a Repeater that can load asynchronously. You can also use `Component.createrObject()` or `Component.incubateObject()` which are attached to every `Item` – Florian Schmidt Aug 09 '16 at 05:53
-
You can imagine `Component` as a prototype of the object. Like a `class MyClass{}` in `C++`. `Instantiator` is a real object which creates items. So these items are parented to `Instantiator`. When you create *instance* of `Component` you should set a parent. – folibis Aug 09 '16 at 05:54