Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.1
-
None
-
Linux
Description
Since QML doesn't support getting the value out of custom enumerations in signals, I tried to circumvent it by making a conversion function that would take in a QVariant containing the enumeration and convert them into integers. Let's assume the signal being as "void foo(EnumContainer::CustomEnumType result);" where CustomEnumType is contained within a QObject-derived class (hereafter referred as EnumContainer), it has been registered with Q_ENUMS and the container class has been registered for QML using qmlRegisterUncreatableType. When you catch this signal in QML, result is of type QVariant(EnumContainer::CustomEnumType), and it is impossible to compare this to any of the enumeration values. Now, if you try to pass this result to a C++ function having a signature of "Q_INVOKABLE int convertEnum(QVariant result);", the parameter result will contain the correct type (result.canConvert<EnumContainer::CustomEnumType>() is true), but its actual contents are random garbage.
This is quite fatal since you can't really work around QML not recognizing custom enumerations as signal parameters currently without extensive hacks in design.