How do I specify an absolute URL for a javascript import?

  • The "help topic on importing JavaScript resources": in QML says:

    bq. JavaScript resources may be imported via either relative or absolute URLs.

    However, I couldn't find any examples of how do do this. As a simple test, under windows, using QML 5.3, I tried moving my utils1.js file to the root of my E drive and then I used

    @import "E:/utils.js" as MyUtils@

    But that generates a "Script e:/utils1.js unavailable" error followed by "e:/utils1.js:-1 Network error". I then tried some other forms with the file prefix but haven't found anything that will work.

  • you can try importing like

    import "../../../../utils1.js" if qml and js are in drive.

Log in to reply

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