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

Enum defined in C++ with -1 is undefined in QML

    XMLWordPrintable

Details

    Description

      C++ CODE:
      class MyClass : QObject {
      Q_OBJECT
          enum MyEnum {
              Invalid = -1,
              Valid1,
              Valid2
          }
          Q_ENUMS( MyEnum )
      };
      
      QML CODE:
      
      function check() {
          console.log( typeof( MyClass.Invalid ) ); // Returns "undefined"
          console.log( typeof( MyClass.Valid1 ) ); // Returns "number" as expected
      }
      

      We've worked around this issue for a long time, but when I ran into it again and did a search I found several old bug reports that seemed to be closed as fixed. However it seems they are not fixed anymore.
      QTBUG-21764
      QTBUG-21672

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            CPendleton Corey Pendleton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes