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

qmllint ignore RegisterEnumClassesUnscoped

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.7
    • 6.4.0
    • QML: Tooling

    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

        Activity

          People

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

            Dates

              Created:
              Updated: