4

to download a console returns the following error:

Frame load interrupted by policy change

Example:

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

Console Preview: enter image description here

Should I configure something in the Compiler or QWebSettings?

Protomen
  • 9,471
  • 9
  • 57
  • 124
  • Maybe the "exe" extension is the source of this allergy. Executables are generally blocked from direct download to avoid malicious code. This may explain the word "policy". – Volkan May 07 '13 at 06:55
  • The download works (I use unsupportedContent(QNetworkReply*) and setForwardUnsupportedContent(true)), the problem really is the strange message. I wonder what it is that message/error. Could you tell me what why it appears? When I download should appear canceled and not failed (as occurs in normal browsers). Will I have to "edit/rewrite" function `unsupportedContent` using `QWebView->setPage(new myClassPageRewrite())` ? – Protomen May 07 '13 at 19:23

2 Answers2

4

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*/
}
Protomen
  • 9,471
  • 9
  • 57
  • 124
1

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.

Jan Kundrát
  • 3,700
  • 1
  • 18
  • 29
  • Thanks for the answer, but my code is downloading normally. I have not used `QWebPage::setLinkDelegationPolicy`. I used `connect(QWebPage, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(signalDownload(QNetworkReply*)));` and `setForwardUnsupportedContent(true)`, the download works perfectly with it. The only problem is the message of `policy` which is strange (I do not understand why this policy or what it is). If you can edit your answer I would be grateful. Good day. – Protomen May 02 '13 at 12:38
  • I can set `setLinkDelegationPolicy` only for `mimetypes` unrecognized? And mimetypes recognized continue to function normally (standard mode)? – Protomen May 02 '13 at 12:41
  • Okay, I've checked the qtwebkit source and it looks like the warning gets printed even in rather harmless cases. It would be interesting to see a backtrace from this error -- ``WebCore::MainResourceLoader::stopLoadingForPolicyChange()`` appears to be the function to set your breakpoint in. How does the stack trace look like? – Jan Kundrát May 02 '13 at 13:25