[Interest] QJSEngine with QRC
Scott Bloom
scott at towel42.com
Wed Oct 29 19:09:26 CET 2025
I have tried that, the problem I am having is the mjs file itself has imports which are not being found.
Let me give some more details.
I have this working via a QRC based html file, using the WebEngine to process the javascript.
The html, uses the qtwebchannel.js from the qrc, and then also loads 3 javascript files via <script src="..."> tags, all via qrc:/ urls. (some of the tags are in the head and some in the body.
This works, however, the overhead of WebEngine is pretty high, so Im trying to find another solution.
I have written a js file that does the same functionality, which is what I am trying to use, but I really don’t care what the solution is, as much as I care about getting it working hopefully with less overhead (just the JS engine)
The project is https://github.com/towel42-com/T42-MathJaxQt6.git
Thanks for any insights you might be able to provide.
Scott
-----Original Message-----
From: Ulf Hermann <ulf.hermann at qt.io>
Sent: Wednesday, October 29, 2025 03:38
To: Qt Interest <interest at qt-project.org>
Cc: Scott Bloom <scott at towel42.com>
Subject: Re: [Interest] QJSEngine with QRC
> For Qt, I have created a QRC file with the node modules, as well as
> the script.mjs
>
> I would like to be able to do something along the lines of
>
> QJSEngine engine;
>
> engine.evaluate( “qrc:/js/script.mjs” )
You probably want to do this:
engine.importModule(":/js/script.mjs");
It will return a QJSValue of whatever the ECMAScript module in script.mjs evaluated to.
best regards,
Ulf Hermann
More information about the Interest
mailing list