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

Inherited classes inside namespace require fully qualified parent

    XMLWordPrintable

Details

    • All

    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

        Activity

          People

            qtbuildsystem Qt Build System Team
            cajus Cajus Pollmeier
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: