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

qmllint ignore RegisterEnumClassesUnscoped

    XMLWordPrintable

Details

    • 82d546611 (dev), cb494c2e0 (6.7), 7da544e86 (dev), 806af3541 (6.7), 65fa7ff2c (6.6), e28fee2d2 (tqtc/lts-6.5), 38e35c2dd (tqtc/lts-6.2), ff024d653 (tqtc/lts-6.2)

    Description

      If I have C++ code like this:

      namespace aaa::Data {                                                                                                                                                           
              Q_NAMESPACE                                                                                                                                                             
              QML_NAMED_ELEMENT(Data)                                                                                                                                                 
              QML_UNCREATABLE("C++ namespace")                                                                                                                                        
              Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")                                                                                                                     
                                                                                                                                                                                      
         enum class DType : uint8_t {                                                                                                                                                 
           A, B                                                                                                                                                                       
         };                                                                                                                                                                           
         Q_ENUM_NS(DType)   
      }
      

      then I can use "DType" enum in QML like this:

      Item {
        property int secret: Data.DType.A  
      }
      

      If I tried to use "Data.A" instead of "Data.DType.A":

      Item {
        property int secret: Data.A  
      }
      

      I got warning during running the application: "Unable to assign [undefined] to int" .

      But qmllint produces no warning about "property int secret: Data.A".
      While usage of "Data.Foo" force it produce warning.

      I suppose this is because of "qmltypes" generated by build system (I use cmake + qt_add_qml_module) do not distinguish between cases when RegisterEnumClassesUnscoped = true and = false.

      It would be nice if qmllint also produces warning like "Unable to assign [undefined] to int"

      Attachments

        Issue Links

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

          Activity

            People

              ulherman Ulf Hermann
              evgeniy_dushistov evgeniy_dushistov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes