c++ - How to download files from QWebView? -


i created small web browser qt creator , qwebview. i's working , pages loading fast. how can make browser capable of downloading files? looked through signals , functions list, did't find me. how can found out if qurl contains link file other text/html can download it?

qwebview has 'qwebpage' member can access it's pointer webview.page() . should look. qwebpage has 2 signals: downloadrequested(..) , unsupportedcontent(..). believe dowloadrequest emitted when user right clicks link , selects 'save link' , unsupportedcontent emitted when target url cannot shown (not html/text).

but unsupportedcontent emitted, should set forwardunsupportedcontent true function webpage.setforwardunsupportedcontent(true). here minimal example have 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, mainwindow::download(..) , mainwindow::unsupportedcontent(..) slots !


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -