I've been struggling with an issue regarding loading a local html file. I'm going off the assumption that a QWebView is the correct way to be trying to display this file. My issue is that while I have the .html file visible when running in Debug, when I attempt to run in Release it is not visible. I am including the file in the appropriate directories, so that's no the issue. Are there any additional settings, libs, dlls that I could be missing? I've got the file specified to the QWebView in Qt Creator in the URL field of the QWebView. It is displayed like below:
file:///C:/devel/projects/myProject/myProject/Resources/page.htm
I've changed the file to a .html as well, it doesn't seem to make a difference.
Thanks, -K
Edit: I've changed it temporarily to:
waiver_webView_2->setUrl(QUrl::fromLocalFile("file:///C:/devel/projects/myProject/myProject/Resources/page.htm"));
Unfortunately this still does not work. I've verified and the file does actually exist there. When I provide that location to the URL via the Qt Creator it works on my developer machine in release but not on a machine I deploy to, DESPITE the folder structure being absolutely identical.
The best I could find was getting the absolute path of the file first and then using that path with QUrl. There's a qt forum post on this topic which I'll put as a source bellow. It can be adapted to your code like so:
waiver_webView->load(QUrl::fromLocalFile(QFileInfo("page.htm").absoluteFilePath()));
QFileInfo also needs to be included.
source https://forum.qt.io/topic/23653/qurl-fromlocalfile-and-relative-path/4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With