Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
6.4.0 Beta3
-
fc683799fe (qt/qtdeclarative/dev) fc683799fe (qt/tqtc-qtdeclarative/dev) 7dde191b41 (qt/qtdeclarative/6.4) 7dde191b41 (qt/tqtc-qtdeclarative/6.4)
Description
QtQuick.Controls routinely employs the following pattern when creating an element of a component:
QQmlContext *creationContext = delegate->creationContext(); if (!creationContext) creationContext = qmlContext(q); QQmlContext *context = new QQmlContext(creationContext, q); context->setContextObject(q); QObject *object = delegate->beginCreate(context);
In the presence of bound components this doesn't work. Bound components can only be created in their creation context, and you cannot set the context object on that. If you want to pass information to instances of bound components, you need to use required properties.
It looks like most of this is cargo culted from elsewhere. We need to figure out:
- what actual information we are passing to the various delegates
- how to encode it into required properties instead
Once this is done, we need to drop the extra contexts.
In cases where it makes sense we can check whether the component is bound and whether it has required properties. If neither is the case we can keep creating the extra contexts in order to support legacy code that relies on context properties.