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

qmlsc should support casting of various int types

    XMLWordPrintable

Details

    • 054f43023 (dev), b13e22f27 (dev), b230eeb32 (6.5), 2b7c81184 (6.5)

    Description

      Existing models that come from some hardware specification typically have some properties that are i.e. quint16. While it is no problem to have them at runtime, qmlsc complains about them like in the attached example:

      Warning: main.qml:14:9: Could not compile function writeValues: Type Druggeljug of Druggeljug does not have a property myInt8 for writing [compiler]
              Druggeljug.myInt8   = 42
              ^^^^^^^^^^
      Warning: main.qml:27:32: Type "qint8" of property "myInt8" not found. This is likely due to a missing dependency entry or a type not being exposed declaratively. 
      [unresolved-type]
              console.log(Druggeljug.myInt8)
                                     ^^^^^^
      Warning: main.qml:27:32: Could not compile function readValues: Cannot load property myInt8 from Druggeljug of Druggeljug. [compiler]
              console.log(Druggeljug.myInt8)
                                     ^^^^^^
      Warning: main.qml:40:20: Could not compile function showValues: type qint8 for argument 0 cannot be resolved [compiler]
              Druggeljug.showMyInt8(1337)
                         ^^^^^^^^^^
      

      Additionally, the compiler for 6.5-dev generates code that gcc does not want to compile for c3.qml:

      [ 77%] Building CXX object CMakeFiles/appsandbox.dir/build/.rcc/qmlcache/appsandbox_c3_qml.cpp.o
      /home/prcs1076/tmp/sandbox/build/.rcc/qmlcache/appsandbox_c3_qml.cpp: In lambda function:
      /home/prcs1076/tmp/sandbox/build/.rcc/qmlcache/appsandbox_c3_qml.cpp:336:35: error: call of overloaded 'QJSPrimitiveValue(uint&)' is ambiguous
        336 | r2_2 = QJSPrimitiveValue(retrieved).toString();
            |                                   ^
      In file included from /home/prcs1076/Projekte/qt6-build/qtbase/include/QtQml/qjsprimitivevalue.h:1,
                       from /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsmanagedvalue.h:8,
                       from /home/prcs1076/Projekte/qt6-build/qtbase/include/QtQml/qjsmanagedvalue.h:1,
                       from /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsengine.h:13,
                       from /home/prcs1076/Projekte/qt6-build/qtbase/include/QtQml/qjsengine.h:1,
                       from /home/prcs1076/tmp/sandbox/build/.rcc/qmlcache/appsandbox_c3_qml.cpp:9:
      /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsprimitivevalue.h:157:14: note: candidate: 'QJSPrimitiveValue::QJSPrimitiveValue(const QVariant&)'
        157 |     explicit QJSPrimitiveValue(const QVariant &variant) noexcept
            |              ^~~~~~~~~~~~~~~~~
      /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsprimitivevalue.h:127:26: note: candidate: 'constexpr QJSPrimitiveValue::QJSPrimitiveValue(double)'
        127 |     Q_IMPLICIT constexpr QJSPrimitiveValue(double value) noexcept : d(value) {}
            |                          ^~~~~~~~~~~~~~~~~
      /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsprimitivevalue.h:126:26: note: candidate: 'constexpr QJSPrimitiveValue::QJSPrimitiveValue(int)'
        126 |     Q_IMPLICIT constexpr QJSPrimitiveValue(int value) noexcept : d(value) {}
            |                          ^~~~~~~~~~~~~~~~~
      /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsprimitivevalue.h:125:26: note: candidate: 'constexpr QJSPrimitiveValue::QJSPrimitiveValue(bool)'
        125 |     Q_IMPLICIT constexpr QJSPrimitiveValue(bool value) noexcept : d(value) {}
            |                          ^~~~~~~~~~~~~~~~~
      /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsprimitivevalue.h:22:7: note: candidate: 'constexpr QJSPrimitiveValue::QJSPrimitiveValue(const QJSPrimit
      iveValue&)'
         22 | class QJSPrimitiveValue
            |       ^~~~~~~~~~~~~~~~~
      /home/prcs1076/Projekte/qt6/qtdeclarative/src/qml/jsapi/qjsprimitivevalue.h:22:7: note: candidate: 'constexpr QJSPrimitiveValue::QJSPrimitiveValue(QJSPrimitiveVal
      ue&&)'
      

      Interrestingly, it compiles main.qml (which contains that type, too) without that error.

      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
              cajus Cajus Pollmeier
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: