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

QML does not allow using C++ enum values which start from a lower-case character in direct bindings

    XMLWordPrintable

Details

    • d29f3d7a62780d74f62330b0e3a0703a72155852 (qt/qtdeclarative/dev)

    Description

      As the title reads, QML does not allow such enum usages:

       

      C++:
      enum class Test { value1, value2 };
      // Let's skip namespace/class declaration and metatypes registration.
      
      QML:
      Item {
          property int v: TestItem.Test.value2
      }

      In this case QML will emit the following error:

       

      Invalid property assignment: Enum value "value2" cannot start with a lowercase letter
      

      I know about the issues like QTBUG-46758 or QTBUG-35494, but they are pretty old and many things changed in Qt since then. In fact such lower-cased enums do work in QML (at least in Qt 5.11 and 5.14). The mentioned direct binding is the only place where we faced the error, and that error message was introduced long ago in 2016, and now it looks a bit irrelevant.

      So far it is possible to work-around the issue by using a code-block with return:

      property int v: { return TestItem.Test.value2 }
      

       

       

       

      Attachments

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

        Activity

          People

            max.goldstein Maximilian Goldstein
            kds Denis Klychkov
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes