Solved Browser : how to download files
-
Hi, i program a browser. i would like to download the files, i use QNetworkAccessManager QNetorwkReply but i don't know how to get a link of file, i searched in doc and i haven't found
Exemple :managet.get(QNetworkRequest(QUrl(http://download.microsoft.com/download/1/7/1/1718ccc4-6315-4d8e-9543-8e28a4e18c4c/dxwebsetup.exe)));
Thank !
-
Hi
This example show how
http://doc.qt.io/qt-5/qtnetwork-download-main-cpp.htmllook in
void DownloadManager::downloadFinished(QNetworkReply *reply) -
void DownloadManager::downloadFinished(QNetworkReply *reply)
Is call when the download is finished, i need just to get a link, for my browser when i click in a link download nothing is happening
-
@Yacinoben
Ok. sounded like you wanted to download file. :)I dont know how your browser can give a link. sorry.
-
@Yacinoben
are you using the QtWebKit module?If so do this:
QWebPage* page = webView->page(); page->setForwardUnsupportedContent( true ); connect(page, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(download(QNetworkRequest))); // called when the "Save-to-disk" action is triggered connect(page, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*))); // called when data cannot be displayed (e.g. non-html content)
-
-
@Yacinoben said:
No, i use Qt WebEngine .
Ok, then take a look at QWebEngineProfile::downloadRequested()
You simply need to set the path (target destination file path) of the incoming QWebEngineDownloadItem object and call accept() on it.
The download/transfer is handled by QtWebEngine internally. -
I'm sorry to reply late, i don't see notification .
It works !! thank you for your help :)