QWebView won't load file from qrc resource
-
I wouldn't really consider that a solution. The web view has to load additional resources (css, js, images), based on the content of the html, and I'd have to literally copy everything to the temp folder. Once this project starts to get big, that's simply not an option.
-
I agree with you. It is not convenient. But I don't see the other way.
I see two issues with putting all html related files as the resources:
When you put all html, js, etc files in the executable file as the resources, how are you going to manage the links inside these html, js, etc files?
If you will put a lot of resources in the executable file it will make the file big and relatively slow to load.
-
I think Qt assistant maybe a good example. Take a look on how they provide and show bunch of html files.
Or something simple like this
-
Extract all files to OS dependent cache directory on first run or after installation
@
QString cacheDir =
QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
@ -
Load the files from the cache directory
-
Provide checksum for the files if you need to protect an app from loading the modified files.
-
-
Thanks for the suggestion. I used exactly what you suggested (except TempLocation instead of CacheLocation), and recursively copied the contents of the resources to the destination folder. Everything works, and files are deleted automatically on program exit on my target platform (linux).
-
This post is deleted!
-
For me, using the
qrc:/
protocol (qrc:/html/index.html
) along with cleaning the project and running qmake worked. But it didn't work by simply using:/html/index.html
or before cleaning the project and running qmake.