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. How to make JS File accessible via module definitions? [SOLVED]
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 824 Views
  • 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 Offline
    F Offline
    Frime
    wrote on 11 May 2015, 12:03 last edited by Frime
    #1

    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

    P 1 Reply Last reply 14 May 2015, 09:16
    0
    • F Frime
      11 May 2015, 12:03

      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

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 14 May 2015, 09:16 last edited by
      #2

      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
      1
      • F Offline
        F Offline
        Frime
        wrote on 29 May 2015, 15:59 last edited by
        #3

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

        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