Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-110108

QML enumeration attributes should not reference own filename

    XMLWordPrintable

Details

    • All

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            paulmasri Paul
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes