Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

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

    QML and Qt Quick
    2
    3
    697
    Loading More Posts
    • 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.
    • F
      Frime last edited by Frime

      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

      p3c0 1 Reply Last reply Reply Quote 0
      • p3c0
        p3c0 Moderators @Frime last edited by

        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.

        157

        1 Reply Last reply Reply Quote 1
        • F
          Frime last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post