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

Create Q_GADGET objects in QML

    XMLWordPrintable

Details

    • e9f650cad82e7eff2234cdf2d37bb9b1bb25d27d

    Description

      It will be nice if we can create Q_GADGET objects in QML not only to use them.

      I'll paste Simon's reply here:

      No objection per-se, but we'd have to figure out some details. For example declarative instantiation is not an object, as the ownership rules do not comply with QObject. That would leave us with a JavaScript
      constructor function, replacing Qt.point(...) for example. But then we'd have to comply with the namespace rules, so we'd have

          qmlRegisterGadget<MyGadget>("MyModule", "ThatName", 1, 0);
      

      and then

          import MyModule 1.0
      

      and in expressions we'd have

          var g = new ThatName();
      

      and the same for a namespaced import:

          import MyModule 1.0 as Foo
          var g = new Foo.ThatName();
      

      It's a bit of work to do, but I don't see a problem in principle.

      I'm adding also :

          import MyModule 1.0 as Foo
          property Foo.ThatName name
      

      Attachments

        Issue Links

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

          Activity

            People

              ulherman Ulf Hermann
              taipan BogDan Vatra
              Votes:
              11 Vote for this issue
              Watchers:
              19 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes