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

Q_NAMESPACE and friends: Handle namespace extensions

    XMLWordPrintable

Details

    Description

      The code below compiles without any warnings/errors. However,

      • QMetaEnum::fromType<NSX:EnumX>.valueToKey(NSX::Foo) returns the correct enum string
      • QMetaEnum::fromType<NSY:EnumY>.valueToKey(NSY::Foo) returns an empty string

       

      namespace NSX {
          enum EnumX { Foo, Bar };
          Q_NAMESPACE
          Q_ENUM_NS(EnumX)
      }
      
      
      namespace NSY { // Original definition of NSY
          enum EnumY { Foo, Bar };
      }
      
      namespace NSY { // Extension of NSY
          Q_NAMESPACE
          Q_ENUM_NS(EnumY)
      }
      

       

      Suggestions

      Ideally, Q_NAMESPACE and Q_ENUM_NS() would work seamlessly in a namespace extension.

      If this is not feasible, moc should at least detect and warn that the implementation is not supported.

       

      Use-case

      This could be useful for extending a 3rd-party library's namespace to allow introspection with QMetaObject.

      Attachments

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

        Activity

          People

            fabiankosmale Fabian Kosmale
            skoh-qt Sze Howe Koh
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes