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

Enum class with the same name as other enum class member don't work in QML

    XMLWordPrintable

Details

    • Windows

    Description

      The following code causes the enum UserType does not work in QML:

      namespace Model {
      Q_NAMESPACE
      
      enum class UserProperty {
          UserType,
          UserId,
      };
      Q_ENUM_NS(UserProperty)
      
      enum class UserType {
          Normal,
          Super,
      };
      Q_ENUM_NS(UserType)
      
      } // namespace model
      

      You can check it attached application.

      I think the code generated by MOC is incorrect (It does not distinguish between Model::UserProperty::UserType and Model::UserType):

      #define QT_MOC_LITERAL(idx, ofs, len) \
          Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
          qptrdiff(offsetof(qt_meta_stringdata_Model_t, stringdata0) + ofs \
              - idx * sizeof(QByteArrayData)) \
          )
      static const qt_meta_stringdata_Model_t qt_meta_stringdata_Model = {
          {
      QT_MOC_LITERAL(0, 0, 5), // "Model"
      QT_MOC_LITERAL(1, 6, 12), // "UserProperty"
      QT_MOC_LITERAL(2, 19, 8), // "UserType"
      QT_MOC_LITERAL(3, 28, 6), // "UserId"
      QT_MOC_LITERAL(4, 35, 6), // "Normal"
      QT_MOC_LITERAL(5, 42, 5) // "Super"    },
          "Model\0UserProperty\0UserType\0UserId\0"
          "Normal\0Super"
      };
      #undef QT_MOC_LITERAL

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              permotion88 Karol Polak
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes