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

completing the concept of QQmlValueTypeProvider::createValueType

    XMLWordPrintable

Details

    • All
    • 3ad9f94ff (dev), c7fd6628d (dev), a09ea6b3d (dev), af76a73c5 (dev)

    Description

      This suggestion is a follow up to this thread on the devel mailing list: https://lists.qt-project.org/pipermail/development/2021-October/041841.html

      Ulf wrote:

      "you can add a static create() function that takes a QJSValue as argument to your class or have a ctor that takes QJSValue. Then register the type using QML_ANONYMOUS and it should be possible to create it from any JavaScript value assigned to it."

      Unfortunately the registered createValueTypeFunc gets only called for a hardcoded selection of types: see QQmlObjectCreator::setPropertyValue. Actually these types correspond to what can be found in qquickvaluetypes_p.h.

      To me it looks like almost everything is in place to allow application code to customize the creation of value types - beside doing the very final step in QQmlObjectCreator::setPropertyValue.

      What I would like to see is that QQmlObjectCreator::setPropertyValue would always call createValueTypeFunc in case one has been registered for the value type.

      Attachments

        1. nestedgadgets.cpp
          3 kB
          Uwe Rathmann
        2. nestedgadgets-ok.cpp
          3 kB
          Uwe Rathmann
        3. padding.cpp
          3 kB
          Uwe Rathmann

        Issue Links

          For Gerrit Dashboard: QTBUG-108789
          # Subject Branch Project Status CR V

          Activity

            People

              ulherman Ulf Hermann
              uwe Uwe Rathmann
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes