Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. qmllint Qt 6.3.0 beta3 compile Type error on signal handler
Forum Updated to NodeBB v4.3 + New Features

qmllint Qt 6.3.0 beta3 compile Type error on signal handler

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 430 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jbrend
    wrote on last edited by jbrend
    #1

    Is there a way to write the signal handler (in this case, MouseArea.onWheel(WheelEvent wheel) so that the below noted qmllint warning regarding a type error is not raised?

    The code seems to otherwise work just fine.

    Environment: Qt 6.3.0 beta3 on Kubuntu Linux 21.10
    main.qml

    import QtQuick
    
    Text {
        id: root
        width: 200
        text: `exampleValue: ${exampleValue.toPrecision(4)}`
        horizontalAlignment: Text.AlignHCenter
        property real exampleValue: 3.0
        
        MouseArea {
            id: mouse
            anchors.fill: parent
            onWheel: function (wheel) {
                root.exampleValue += root.exampleValue * (wheel.angleDelta.y / 1200) 
            }
        }
    }
    

    qmllint output:

    $ qmllint --compiler warning main.qml
    Info: main.qml:13:18: Could not compile binding for onWheel: Type error: could not infer the type of an expression
            onWheel: function (wheel) {
                     ^^^^^^^^^
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      jbrend
      wrote on last edited by jbrend
      #2

      Based on this presentation, it looks like the goal is to add support for TypeScript-like type annotations in order for the script to be compilable.

      How To Use QML in Qt6
      https://www.youtube.com/watch?v=4ji6D6UpA54
      32:53

      It seems like the detection tool (qmllint) is ahead of the language support because if I try that:

      onWheel: function (wheel: WheelEvent) {
          root.exampleValue += root.exampleValue * (wheel.angleDelta.y / 1200) 
      }
      

      I get this:

      $ qmllint --compiler warning main.qml
      main.qml:13:33: Type annotations are not permitted in function parameters in JavaScript functions
      

      ... and this (showing it's not just a spurious tool warning):

      $ qml main.qml
      QQmlApplicationEngine failed to load component
      file:///xxxx/Wheelies/main.qml:13:33: Type annotations are not permitted in function parameters in JavaScript functions
      qml: Did not load any objects, exiting.
      

      This page on qmllint does not state explicitly whether the tool is in Technical Preview as of Qt 6.3.0 beta3 or Qt 6.4.
      https://doc-snapshots.qt.io/qt6-dev/qtquick-tool-qmllint.html

      Neither does the tool's help.

      I found this in the interest@qt-project.org mailing list regarding adding type annotations. If I'm reading it correctly, support is already there, but qml cannot run the file with the type annotation as of Qt 6.3.0 beta3 (see above):
      https://codereview.qt-project.org/c/qt/qtdeclarative/+/249400

      Does anyone know more?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved