Can't receive download requests from the QWebPage in Qt

971 views Asked by At

I am trying to create a download manager for a QGraphicsWebView and so far it works good except one thing: I cannot send the download request from the QWebPage to the download manager.

QObject::connect(webPage, SIGNAL(downloadRequested(const QNetworkRequest&)),
                 this, SLOT(downloadRequested(const QNetworkRequest&)));

This is my code for connecting the download request signal to the slot that sends the request forward, to the download manager. I put a qDebug() message in the slot before the other actions and the message isn't displayed. This means the signal isn't sent when I click a link to a file.

Is there a way I could send a signal when the user clicks a link to a file?

2

There are 2 answers

3
alexisdm On BEST ANSWER

The downloadRequested(QNetworkRequest) signal is only emitted when you right click on the link, and then click on the "Save link..." item of the context menu.

When the user clicks on a link to something that is supposed to be downloaded (with the HTTP field Content-Disposition: attachment; filename=...), QWebPage emits the unsupportedContent(QNetworkReply*) signal.

0
Blastcore On