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. Is it possible to set argument types in JS functions for code completion?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to set argument types in JS functions for code completion?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 522 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.
  • K Offline
    K Offline
    Kobid
    wrote on last edited by
    #1

    Hi,
    For example. When I declare this variable:

    function baseHttpRequest(endPoint, onDoneCallback, onErrorCallback) {
            var request = new XMLHttpRequest();
            request.onreadystatechange = function() {
                if (request.readyState === XMLHttpRequest.DONE) {
                    if (request.status === 200) {
                        onDoneCallback(request);
                    } else {
                        onErrorCallback(request);
                    }
                }
            }
        }
    

    Qt Creator in this context know variable type and when I type request. (dot), it suggest object properties etc. But when I pass this object in function argument:

    function myFunction( req: XMLHttpRequest ) {
    }
    

    then when I type req. I don't see any suggestions which is expected due to JavaScript nature. I'm also getting this warning:
    [object Object] should be coerced to void because the function called is insufficiently annotated. The original value is retained. This will change in a future version of Qt
    So we must wait or is there any workaround / trick in QML world? My workaround is split wanted values from object as base types:

    onErrorCallback(status: int, statustext: string, content: string);
    

    I know that this topic is stupid for java scripters which are used to but I'm "typed" programmer and I like to see types :P

    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