Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-106042

QtQuick.Controls creates delegates in separate contexts

XMLWordPrintable

    • fc683799fe (qt/qtdeclarative/dev) fc683799fe (qt/tqtc-qtdeclarative/dev) 7dde191b41 (qt/qtdeclarative/6.4) 7dde191b41 (qt/tqtc-qtdeclarative/6.4)

      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:

      1. what actual information we are passing to the various delegates
      2. 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.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            mitch_curtis Mitch Curtis
            ulherman Ulf Hermann
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes