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. Adding the type annotations required for Qt Quick Compiler
Forum Updated to NodeBB v4.3 + New Features

Adding the type annotations required for Qt Quick Compiler

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 325 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    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?

    A 1 Reply Last reply
    0
    • A Asperamanca

      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?

      A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      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
              }
          }
      
      1 Reply Last reply
      0
      • A Asperamanca has marked this topic as solved on

      • Login

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