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

moc: namespaced base class not properly resolved in cpp.json file

    XMLWordPrintable

Details

    • All
    • cbb4aea21 (dev), 3092406d7 (6.7), a4817f47f (6.6), 17c9ad928 (tqtc/lts-6.5), 672a82463 (dev), 28a88b598 (6.7), bdb4663ee (6.6), b5266a1f2 (tqtc/lts-6.5)

    Description

      Moc takes the base class name of a Q_OBJECT'ed class as-is from the source code. Cf. Girl example of OP. This doesn't matter much for moc_.cpp, because the C++ compiler will perform name lookup, and thus find model::Person but in the moc_.cpp.json file, the scope is missing and tools using the JSON information either need to perform their own name lookup or fail to find the base class.

      Since moc needs to know about the base class(es) of a moc'ed class, it seems weird that it wouldn't resolve base class names to FQN before storing them in the generated files.

      Old description:

      When using inheritance for namespaced classes that export QML related entities, the behaviour is a bit odd:

      namespace model {
      
      class Person {...}
      
      class Boy : public model::Person
      {
          Q_OBJECT
          QML_NAMED_ELEMENT(Boy)
      public:
          Boy(QObject * parent = nullptr) : Person(parent) {}
      };
      
      }
      

      works fine, while

      namespace model {
      
      class Person {...}
      
      class Girl : public Person
      {
          Q_OBJECT
          QML_ELEMENT
      public:
          Girl(QObject * parent = nullptr) : Person(parent) {}
      };
      
      }
      

      does not:

      Warning: main.qml: Object type model::Girl is not derived from QObject or QQmlComponent
      
      Warning: main.qml:15:9: Could not compile binding for onCompleted: Type model::Girl of ??::bar with type model::Girl does not have a property shoeSize for writing
      
              bar.shoeSize = 123
      
              ^^^
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-101141
          # Subject Branch Project Status CR V

          Activity

            People

              mmutz Marc Mutz
              cajus Cajus Pollmeier
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: