[SOLVED] Display HTML from QRC in WebEngineView
-
wrote on 10 Aug 2015, 18:23 last edited by Nathan H
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. :)
-
wrote on 12 Aug 2015, 14:17 last edited by
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? -
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. -
@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. -
wrote on 14 Aug 2015, 18:35 last edited by
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.
-
wrote on 14 Aug 2015, 20:23 last edited by
OK, so I just tried it again and now it works. No idea what's different from earlier this week, but I'm glad it works now. :]
7/7