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

Moc tool removes enum keyword from namespaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.3
    • Build tools: moc
    • None
    • Windows 10 PC
    • Windows

    Description

      I just upgraded to Qt 6.2.3 and I'm now getting errors in one of my moc files for a class that uses an enum in one of its slots.  The enum is inside of a namespace called enums, and in the moc file the enum part of the namespace name is being removed.  This looks very similar to the bug QTBUG-88125 which was apparently fixed in Qt 5.15, but still seems to be a problem in Qt 6.  I have attached a small sample project that reproduces the problem.

       

      Class.h

      #ifndef CLASS_H
      #define CLASS_H
      #include <QObject>
      
      namespace enums
      {
          enum class Cards
          {
              Clubs,
              Diamonds,
              Hearts,
              Spades
          };
      }
      
      class Class : public QObject
      {
          Q_OBJECT
      
      public:
          Class() {}
      
      signals:
          void cardPicked(enums::Cards card);
      
      public slots:
          void setCard(enums::Cards card) {}
      };
      
      #endif // CLASS_H
      

       

      main.cpp

      #include <QCoreApplication>
      #include "Class.h"
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
          Class c;
      
          QObject::connect(&c, &Class::cardPicked, &c, &Class::setCard);
      
          return a.exec();
      }
      

      Errors

      Attachments

        Issue Links

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

          Activity

            People

              fabiankosmale Fabian Kosmale
              davidmitchell David Mitchell
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes