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]>
Date: Saturday, 27. September 2025 at 02:12
To: List for announcements regarding Qt releases and development via Announce 
via Development <[email protected]>, Nuno Santos via Interest 
<[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