How to import JS file into QJSEngine?



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


Log in to reply
 

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