How to make JS File accessible via module definitions? [SOLVED]



  • Hi community!

    I have a (pragma singleton) java script file which i would like to make accessible via a module definition.
    This looks as follows:

    module MyModule 
    MyJsFile 1.0 /path/to/file.js
    // ..some other Controls...
    

    Now, i would like to access my functions in another (module-extern) file:

    import MyModule 1.0
    // So... what to do now?
    // something like this? (doesn't work)
    import MyModule.MyJsFile 1.0 as "MyJS"
    MyJs.doIt();
    

    Any help is welcome!

    Thanks in advance,
    Frime


  • Moderators

    Hi @Frime, A little late reply.
    Check the following example. According to it you just need to specify the JavaScript file in qmldir. And to to use it no need to import it separately. The JS functions are directly accessible as the module is already imported.



  • Hi!
    Yep. That works. Thank you very much!
    ...That was too easy ^^


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.