Qt 6.11 is out! See what's new in the release
blog
Adding the type annotations required for Qt Quick Compiler
-
I have the following QML signal handler:
onActiveTranslationChanged: function (translation) { // Do something with translation }This gives me the warning:
:-1: warning: Could not compile binding for onActiveTranslationChanged: Functions without type annotations won't be compiled [compiler]However, when I try to add type annotations like so
onActiveTranslationChanged: function (translation: vector2d)I get the error:
error: Type annotations are not permitted in function parameters in JavaScript functionsHow do I do it right?
-
I have the following QML signal handler:
onActiveTranslationChanged: function (translation) { // Do something with translation }This gives me the warning:
:-1: warning: Could not compile binding for onActiveTranslationChanged: Functions without type annotations won't be compiled [compiler]However, when I try to add type annotations like so
onActiveTranslationChanged: function (translation: vector2d)I get the error:
error: Type annotations are not permitted in function parameters in JavaScript functionsHow do I do it right?
Answering my own question.
The simplest way seems to sidestep the issue by using the component's property value instead of the signal handler parameter:DragHandler { id: dragHandler // other properties onActiveTranslationChanged: { // Use dragHandler.activeTranslation instead of parameter } } -
A Asperamanca has marked this topic as solved on