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

Problem with QtQuickCompiler and QObject enumeration

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P1: Critical
    • None
    • 5.12.4
    • QML: Compiler
    • Build machine; Windows 7 Pro 64bit
      Qt Versions:
      - Qt 15.2.4 for Windows 32 bits
      - Qt 15.2.4 for Android ARM
    • Android, Windows

    Description

      Hi all,

      I am modernizing our application from Qt 5.4.2 to last LTS version (Qt 5.12.4). While doing this, I think I've found a bug in qtquickcompiler.

       

      I have declared a QQuickPaintedItem object, which has an enumeration to defined drawing types, like this:

      class TourPlayerItem : public QQuickPaintedItem {
          Q_OBJECT
      public:
          enum DrawType
          {
              DrawTypeNormal,
              DrawTypeBackward,
              DrawTypeWorkRegion,
              DrawTypeContainerRegionSingle,
              DrawTypeContainerRegionDouble,
              DrawTypeOffline,
              ...
              };
      #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
          Q_ENUMS(DrawType)
      #else
          Q_ENUM(DrawType)
      #endif
      ...
      }
      

       

      This class is registered to be accessible from QML:

      qmlRegisterType<TourPlayerItem>("com.Geocept.Tour", 1, 0, "GCTourPlayer");
      

       

      In QML, this class is used like this:

      GCTourPlayer {
          id: tourPlayerTrace 
          anchors.fill: parent
          drawTypes: [
              DrawType { type: GCTourPlayer.DrawTypeBackward; color: '#D9004D9E' },
              DrawType { type: GCTourPlayer.DrawTypeWorkRegion; color: '#E67814A0' }
          ]
      }
      

       

      This works fine with Qt 5.4.2 and with Qt 5.12.4 only if QtQuickCompiler is disabled.

      When QtQuickCompiler is enabled, type is always set to '0'.

      I've got the same issue on Windows and on Android

      Attachments

        1. main.cpp
          0.8 kB
        2. main.qml
          0.5 kB
        3. qml.qrc
          0.1 kB
        4. QmlEnumTest.pro
          1 kB
        5. TourPlayerItem.cpp
          3 kB
        6. TourPlayerItem.h
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            shausman Simon Hausmann
            kromignon Fabrice Mousset
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes