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

Fabrice Mousset | GEOCEPT GmbH fabrice.mousset at geocept.com
Tue Aug 20 18:05:39 CEST 2019


I've got this issue when qtquickcompiler is enabled!
When I remove qtquickcompiler, it works!

Regards

Fabrice Mousset

> -----Ursprüngliche Nachricht-----
> Von: Development <development-bounces at qt-project.org> Im Auftrag von
> Fabrice Mousset | GEOCEPT GmbH
> Gesendet: Dienstag, 20. August 2019 18:00
> An: development at qt-project.org
> Betreff: [Development] QObject enum not readable in QML with Qt 5.12.4
> 
> 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
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development


More information about the Development mailing list