QWebView has a QWebPage member, which you can access to this pointer using webView.page() . Here you have to look. QWebPage has two signals: downloadRequested(..) and unsupportedContent(..) . I believe that dowloadRequest is only issued when the user right-clicks the link and select "Save Link", and unsupportedContent is issued when the destination URL cannot be shown (and not html / text).
But for unsupported Content to be emitted, you must set forwardUnsupportedContent to True using the webPage.setForwardUnsupportedContent(true) function. Here is the minimal example I created:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->webView->page()->setForwardUnsupportedContent(true); connect(ui->webView->page(),SIGNAL(downloadRequested(QNetworkRequest)),this,SLOT(download(QNetworkRequest))); connect(ui->webView->page(),SIGNAL(unsupportedContent(QNetworkReply*)),this,SLOT(unsupportedContent(QNetworkReply*))); } MainWindow::~MainWindow() { delete ui; } void MainWindow::download(const QNetworkRequest &request){ qDebug()<<"Download Requested: "<<request.url(); } void MainWindow::unsupportedContent(QNetworkReply * reply){ qDebug()<<"Unsupported Content: "<<reply->url(); }
Remember that MainWindow :: download (..) and MainWindow :: unsupportedContent (..) are SLOT !
Heyo source share