Qt World Summit: Register Today!

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

  • The "help topic on importing JavaScript resources": http://qt-project.org/doc/qt-5/qtqml-javascript-imports.html 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.

  • Qt Champions 2017

    you can try importing like

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

Log in to reply