Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
6.4.2
-
None
Description
As per the documentation (https://doc.qt.io/qt-6/qtqml-syntax-objectattributes.html#enumeration-attributes), an enum declared in QML is referenced as <Type>.<EnumerationType>.<Value> or <Type>.<Value>.
where <Type> is the QML filename in which it is defined.
Referencing the enum in this way from outside the component makes sense and is consistent with enums defined in C++.
However it seems to me to be poor programming practice for references to the enum from within the component to have to reference the component's own filename as this is fragile to file renaming.
I would like to suggest that within the component that defines an enum it should be referenced as <EnumerationType>.<Value> where there is understanding that <EnumerationType> takes scope precedence over any external <Type>.<Value> that happens to share the same name.
Alternatively there could be a new reserved token This (capitalised) to be used as This.<EnumerationType>.<Value>.
Either solution could be adopted with little risk of breaking existing code and the added benefit of less code fragility.