I always put my Enum into C++, the sad part is that you need to create a dummy class to be exposeed to contain the enum. This make it possible to use the enum into Qml and C++. Enum from Qml are not super fun to be used. Can make function that convert the int value to the enum. Make an enum to string converter function too into C++. That will ease the tr() too.
-----Original Message----- From: Interest <interest-boun...@qt-project.org> On Behalf Of Jason H Sent: March 19, 2020 10:04 AM To: interestqt-project.org <interest@qt-project.org>; Ulf Hermann <ulf.herm...@qt.io> Subject: [Interest] Will Qt6 end this enum issue? (or even 5.15?) The enums in QML are expressed as ints when printed. console.log(camera.position) => 1 I work around this as: property var positions: ["Unspecified", "BackFace", "FrontFace"] onPositionChanged: console.log(positions[position]); Or worse yet: property var flashModes: { 1: "FlashAuto", 2: "FlashOff", 4: "FlashOn", 8: "FlashRedEyeReduction", 16: "FlashFill", 32: "FlashTorch", 64: "FlashVideoLight", 128: "FlashSlowSyncFrontCurtain", 256: "FlashSlowSyncRearCurtain", 512: "FlashManual" } It seems that enums should be class with a value and label console.log(camera.position.label) => "BackFace" console.log(camera.position.value) => 1 Though I can understand if this might not be the preferred way. It's just I spend so much time doing this. I'm open to anything really console.log(Camera.positionEnum(camera.position).label) == "BackFace" console.log(Camera.positionEnum(camera.position).value) == 1 or console.log(Qt.enum(camera.position).label) == "BackFace" console.log(Qt.enum(camera.position).value) == 1 Also, in Qt I occasionally encounter enums that are not registered and cannot be used in QML without registering them myself. Will Qt registering all enums for use in QML be standard for Qt 6? _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest