Adding the type annotations required for Qt Quick Compiler
Solved
QML and Qt Quick
-
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 functions
How 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 } }
-