Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How do I specify an absolute URL for a javascript import?
Qt 6.12 LTS is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.7k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      you can try importing like

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

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      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
      • Unsolved