[SOLVED] Display HTML from QRC in WebEngineView
-
I would like to display HTML files (with associated JS and CSS) that get bundled with my application in QRC in a WebEngineView (I'd prefer to use QML, but if necessary I can use widgets). How can I do this? I've tried loading "qrc:/index.html" as the URL in both a QML and widgets based application, and in both cases the web engine assumes index.html is a domain and fails on the DNS lookup.
Where am I going wrong here? Thanks. :)
-
I would like to display HTML files (with associated JS and CSS) that get bundled with my application in QRC in a WebEngineView (I'd prefer to use QML, but if necessary I can use widgets). How can I do this? I've tried loading "qrc:/index.html" as the URL in both a QML and widgets based application, and in both cases the web engine assumes index.html is a domain and fails on the DNS lookup.
Where am I going wrong here? Thanks. :)
-
I've looked at using
loadHTML
, but the page I'm loading pulls in external resources like image, JS and CSS files. How do I load those when those files are also in QRC? -
@Nathan-H AFAIK it will work. Try using
qrc:/
before source files.
P.S: Good news is loading HTML file from qrc now works in Qt 5.5. -
Using a qrc:/ url definitely works. I routinely load css and js files into a WebEngineView with urls (inside the html) like "qrc:/blah.js" and setting the url of a WebEngineView to "qrc:/index.html" also works as expected. If it's not working for you, there's some other problem.