Changing the QQmlContext for a QML object?

1.2k views Asked by At

Evidently, even when objects are detached from the existing parent and attached to a new one, when the old parent context is destroyed, so is the object.

The first solution that comes to mind is to create the object in a persistent context. However, then dynamic scope properties will not work for it. Which is critical for my use case. I can't get things running if the object is not in the context of the object it is parented to, and the parent changes. Additionally, functions can no longer be invoked, even if the target objects have the functions, because QML attempted to evaluate a function in an invalid context.

Tried resorting to QQmlEngine::setContextForObject() and QQmlEngine::contextForObject() just to discover that once set, the context cannot be reset.

So, any fresh ideas?

0

There are 0 answers