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

enum as object for generated code

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11

      Description

      For such C++ code:

      class Foo : public QObject
      {
          Q_OBJECT
          Q_PROPERTY(Boo::NamespaceE v1 MEMBER v1_ FINAL)
          Q_PROPERTY(Moo::NamespaceE v2 MEMBER v2_ FINAL)
      public:
          explicit Foo(QObject *parent = nullptr);
      
      private:
          Boo::NamespaceE v1_ = Boo::NamespaceE::Magnetic;
          Moo::NamespaceE v2_ = Moo::NamespaceE::Magnetic;
      };
      

      and QML code:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import Cpp 1.0
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
          Foo {
              id: foo
          }
      
          Component.onCompleted: {
              console.log("typeof v1", typeof(foo.v1));
              console.log("typeof v2", typeof(foo.v2));
          }
      }
      

      qml engine prints:

      qml: typeof v1 number
      qml: typeof v2 object
      

      Files where defined Boo and Moo namespaces are completely identical (
      if replace Boo with Moo or vise versa).

      The only difference that "boo.h" defined inside source tree where "moo.hpp" is generated during code build. The full project (CMakeLists.txt and all sources) attached as zip archive.

      The interesting part that if I move moo.hpp from ${CMAKE_CURRENT_BINARY_DIR}/gen-code to ${CMAKE_CURRENT_BINARY_DIR} all works fine and qml engine prints "v2 number".
      The moc_*.cpp files looks identical (excluding part where source files was including), so this should not be "moc" bug.

        Attachments

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

          Activity

            People

            Assignee:
            qtqmlteam Qt Qml Team User
            Reporter:
            evgeniy_dushistov evgeniy_dushistov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes