qmllint Qt 6.3.0 beta3 compile Type error on signal handler
-
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.qmlimport 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) { ^^^^^^^^^
-
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:53It 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.htmlNeither 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/+/249400Does anyone know more?