[Development] QObject enum not readable in QML with Qt 5.12.4

Fabrice Mousset | GEOCEPT GmbH fabrice.mousset at geocept.com
Tue Aug 20 17:59:36 CEST 2019


Hi all,

I am **modernizing** our application from Qt 5.4.2 to last LTS version (Qt 5.12.4).
I have a problem which I can't understand and needs some help.

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 // used also for draw order!
    {
        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.DrawTypeSubSections; color: '#E67814A0' }
            ]
        }

When I do this, I've got always '0' for type (color value is working well).
When I replace "GCTourPlayer.DrawTypeBackward " and "GCTourPlayer.DrawTypeSubSections" with corresponding integer value, type is set with excepted value.

This works without any problem with Qt 5.4.2.

Do I something wrong?

Thanks for any helps

Best regards

Fabrice


More information about the Development mailing list