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

qt_add_qml_module does not register QML_SINGLETON classes if version starts with 0

    XMLWordPrintable

Details

    • ad01abe1a (dev), 5f860b786 (6.6), a83503392 (tqtc/lts-6.5)

    Description

      QTBUG-104373 was fixed for general QML_ELEMENT but not for QML_SINGLETON. See attached project.

       

      Code
      mytype.h

      class MyType : public QObject
      {
          Q_OBJECT
          QML_ELEMENT
      
      public:
          explicit MyType(QObject *parent = nullptr) : QObject(parent) {}
          Q_INVOKABLE QString name() const { return u"Foo"_qs; }
      };
      
      class MySingleton : public QObject
      {
          Q_OBJECT
          QML_ELEMENT
          QML_SINGLETON
      
      public:
          explicit MySingleton(QObject *parent = nullptr) : QObject(parent) {}
          Q_INVOKABLE QString name() const { return u"Bar"_qs; }
      };
      

       

      Main.qml

      import QtQuick
      import Version0
      
      Window {
          width: 640
          height: 480
          visible: true
      
          MyType { id: cppObj }
      
          Component.onCompleted: {
              console.log(cppObj.name())
              console.log(MySingleton.name())
          }
      }
      
      

       

      Expected output (Version == 1.0)

      qml: Foo
      qml: Bar
      

       

      Actual output (Version == 0.1)

      qml: Foo
      qrc:/qt/qml/Version0/Main.qml:13: ReferenceError: MySingleton is not defined
      

      Attachments

        Issue Links

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

          Activity

            People

              semlanik Alexey Edelev
              skoh-qt Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes