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

Allow exporting enums from C++ to QML without wraping them in a QObject

    XMLWordPrintable

Details

    Description

      Right now, the only possibility to use C++ enums in QML is to wrap them in a QObject and then export the entire QObject to QML.
      It would be much more convenient if exporting an enum directly would be possible.

      The desired workflow for that would be something like this:
      code
      enum Weather

      { Raining, Sunny, Cloudy }

      ;
      Q_DECLARE_METATYPE(Weather)
      qmlRegisterType<Weather>("Foo", 1, 0, "Weather");
      code

      Ideally, the enum should not only be supported as a function parameter or return value when invoking C++ code, but also as properties in QML, as QTBUG-15483 describes.

      Attachments

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              tmcguire Thomas McGuire
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes