PDA

View Full Version : [webkit] how to downlad file by simple click



maston
29th June 2010, 14:35
Hi.

I have to download file from page using webkit. When I click RMB it showed contentmenu with "save link..." option.
But I need to detect download request by LMB.

downloadRequested() signal is emitted only when i use right button. How to force webkit to download file using single click by left mouse button?

Thanks

maston
29th June 2010, 23:45
after 10h search i found solution.



QNetworkAccessManager *manager = new QNetworkAccessManager(this);
ui->webView->page()->setNetworkAccessManager(manager);
connect(manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));



slot:


void MainWindow::replyFinished(QNetworkReply *reply)
{

if(reply->rawHeader("Content-Type")!="text/html")
{
// code to execute download
}

}