Downloading from qrc:// using the QtWebKit - QWebView
-
Hi.
I'm coding a basic browser using QWebView.
I need all sources to be compiled into the application; for that I used
the Qt Resource System and it has been working great for HTML, CSS, JavaScript, fonts, etc.., all but the
functionality to 'download' a file that is inside it.Somewhere inside the HTML code there is a link pointing to a file inside the qrc origin like this:
@<a href="files/1_3_activity_sheet_1a(ii)_my_skills_profile.docx">Download this file</a>@
Copying the link this is what is put into the clipboard: qrc:/website/files/1_3_activity_sheet_1a(ii)_my_skills_profile.docx
Using the 'inspect' option in the WebKit I found out that the browser was giving out these warnings/errors:WARNING:
@Resource interpreted as Document but transferred with MIME type application/zip: "qrc:/website/files/1_3_activity_sheet_1a(ii)_my_skills_profile.docx".@ERROR:
@GET qrc:/website/files/1_3_activity_sheet_1a(ii)_my_skills_profile.docx Frame load interrupted by policy change qrc:/website/files/1_3_activity_sheet_1a(ii)_my_skills_profile.docx:1@This is the way I set up my QWebSettings:
@
settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
@Is this something that definitely can't be done?, or Is there any workaround for this?
Thanks,
Sergio -
since webkit is just a web viewer and it doesn't provide the downloader, you must handle MIME types yourself and process any files which is NOT known as a web page or web element with your own handler.
webkit can only give you the most important part of a complete web browser in addition brings you the ability of using your c++ code on any web element to have full control on elements and passing calls to each other using "Signals and Slots Mechanism":http://qt-project.org/doc/qt-4.8/signalsandslots.html