Stefan Monov
Stefan Monov

Reputation: 11732

When exactly is "Component.completed" fired?

When exactly is "Component.completed" fired?

The docs say this:

Emitted after the object has been instantiated.

And if this was C++, I'd know that, since the object has been instantiated, I can rely on the constructor to have been executed, with all the guarantees that come from that.

But in QML I don't know what guarantees I have about an object that "has been instantiated". That memory has been allocated for it? That its properties have evaluated and received their initial values? That the whole descendant subtree has been loaded?

Upvotes: 1

Views: 289

Answers (1)

dtech
dtech

Reputation: 49289

The guarantee is it will be fired after the object has been completed. That includes the allocation of memory, construction of object and rigging of property bindings, initial evaluations and such.

What is not guaranteed is the order in which completed signals are handled when objects are nested in a tree. You should not rely on that. An object will not be completed before its entire object tree is completed, but for some inexplicable reason, you can't expect notifications to arrive in the tree-defined order.

Upvotes: 1

Related Questions