Just a note, the reason (at least for me) to the major confusion is every 
example that uses QWebChannel loads java script from a qrc in the html file 
(qrc:/qtwebchannel/qwebchannel.js)

But this issue only pops up if the top level JS calls/imports something else 
from the QRC

Scott

From: Scott Bloom
Sent: Tuesday, September 30, 2025 14:03
To: Kaloyan Chehlarski <[email protected]>; [email protected]
Subject: RE: [Development] QRC based javascript source in QWebEngineView

Thanks.  That was it.

Suggestion, and I file a bug against doc/examples if need be.

At least one of the QWebEngineXXX (potentially the recipe browser example) 
should show and use this.

IMO, a warning for it should be in the QWebEngineView load/setUrl commands.

Scott

From: Development 
<[email protected]<mailto:[email protected]>> 
On Behalf Of Kaloyan Chehlarski via Development
Sent: Tuesday, September 30, 2025 03:48
To: [email protected]<mailto:[email protected]>
Subject: Re: [Development] QRC based javascript source in QWebEngineView

Hi Scott,

By default, support for the Fetch API is not enabled for the QRC scheme. You 
can override the defaults by adding this to your main function:

QWebEngineUrlScheme qrcScheme(QByteArrayLiteral("qrc"));
qrcScheme.setFlags(QWebEngineUrlScheme::FetchApiAllowed);
QWebEngineUrlScheme::registerScheme(qrcScheme);

Make sure to read through the 
documentation<https://doc.qt.io/qt-6/qwebengineurlscheme.html#Flag-enum> for 
all the different flags you can enable. Also note that this needs to be done 
very early in the app's initialization stage, before any WebEngine objects are 
instantiated.

Cheers,
Kaloyan



Confidential
From: Scott Bloom <[email protected]<mailto:[email protected]>>
Date: Saturday, 27. September 2025 at 02:12
To: List for announcements regarding Qt releases and development via Announce 
via Development 
<[email protected]<mailto:[email protected]>>, Nuno Santos 
via Interest <[email protected]<mailto:[email protected]>>
Subject: [Development] QRC based javascript source in QWebEngineView
Im having problems loading html that has javascript inside of it.

I am loading the URL into the QWebEngineView  via a url that looks like QUrl( 
"qrc:/XXX.html" )

The top level html, uses a standard html tag for <script src="xxxx"> where xxx 
is always relative, there are no QRC based urls inside the html or any imported 
JS files.

However, it seems that the nested import commands in the JS do not look inside 
the QRC, and for some reason I get an error saying

js: Fetch API cannot load qrc:/pathtofile/base.json. URL scheme "qrc" is not 
supported.

I have confirmed that the file DOES exist from the C++ QFile based world, but 
Im stumped trying to figure out what is going on.

Is there anyway to track this down?

Scott


-- 
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to