Error downloading

别说谁变了你拦得住时间么 提交于 2020-01-14 22:46:26

问题


to download a console returns the following error:

Frame load interrupted by policy change

Example:

<a href="app.exe">Start Download</a>

Console Preview:

Should I configure something in the Compiler or QWebSettings?


回答1:


I discovered. In conventional Webkit browsers, the place to download the console shows how the request canceled, so before turning to "download manager" of the browser the request should be canceled.

solution:

//replace [QWebView] by your WebView
connect([QWebView]->page(), SIGNAL(unsupportedContent(QNetworkReply*)),
this, SLOT(downloadContent(QNetworkReply*)));

...

void [main class]::downloadContent(QNetworkReply *reply){
    //Replace "[main class]" by "Class" having the signs used in WebView.

    [QWebView]->stop();
    //solution: stop loading --replace [QWebView] by your WebView

    /*function to donwload*/
}



回答2:


Edit: hard to tell without a proper backtrace I requested in the comments, but it looks like the warning might actually be harmless.

Original: That's because the QWebView doesn't know what to do with your app.exe file -- it's not an HTML page or a text/plain document or a supported image, after all. The QWebView class is not a web browser; you apparently want to start a download of some file, but there's no full-blown download manager in that class. You will have to provide your own code for this -- the code will have to ask for a proper location to save it, etc.

You can start with QWebPage::setLinkDelegationPolicy and handle this particular click yourself.



来源:https://stackoverflow.com/questions/16278747/error-downloading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!