Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to import JS file into QJSEngine?
Forum Update on Monday, May 27th 2025

How to import JS file into QJSEngine?

Scheduled Pinned Locked Moved General and Desktop
qt quickqmljavascript
1 Posts 1 Posters 896 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.
  • K Offline
    K Offline
    Korchkidu
    wrote on last edited by
    #1

    Hi,

    I have a QML / C++ application which embeds a QJSEngine. For the GUI, I created JS files containing JS functions that QML components import and call.

    // My QML Component
    import "../JS/Utility.js" as Utility
    [...]
    var result = Utility.myFunction()
    

    Now, I would lile to expose this to the QJSEngine too. Is this possible? I tried using the import statement in my JS scripts and use the QJSEngine::evaluate function but it seems this does not work (or I did something wrong).

    Thanks for any help.
    Best regards.

    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