For what ever reason can't get QWenEngineProfile to invoke downloadRequest when downloading a file with QWebEnginePage. The way I understand it is that when QWebEnginePage::download() is called the QWebEningeProfile::downloadRequested() signal is emitted but for some reason my code doesn't catch the signal.
mainwindow.ccp
WebPageDownload *webPageDownload = new WebPageDownload(this);
webPageDownload->download("https://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download", "file.cvs");
WebPageDownload *webPageDownload = new WebPageDownload(this);
webPageDownload->download("https://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download", "file.cvs");
To copy to clipboard, switch view to plain text mode
webpagedownload.cpp
WebPageDownload
::WebPageDownload(QObject *parent
){page = new QWebEnginePage(parent);
connect(page->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
}
void WebPageDownload
::download(const QUrl &url,
const QString &filename
){ qDebug()<<"download called";
//this should emit QWebEngineProfile::downloadRequested
page->download(url, filename);
}
void WebPageDownload::downloadRequested(QWebEngineDownloadItem* download) {
qDebug()<<"Download request invoked";
}
WebPageDownload::WebPageDownload(QObject *parent){
page = new QWebEnginePage(parent);
connect(page->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
}
void WebPageDownload::download(const QUrl &url, const QString &filename){
qDebug()<<"download called";
//this should emit QWebEngineProfile::downloadRequested
page->download(url, filename);
}
void WebPageDownload::downloadRequested(QWebEngineDownloadItem* download) {
qDebug()<<"Download request invoked";
}
To copy to clipboard, switch view to plain text mode
webpagedownload.h
class WebPageDownload
: public QObject{Q_OBJECT
public:
WebPageDownload
(QObject *parent
= nullptr
);
private:
QWebEnginePage *page;
private slots:
void downloadRequested(QWebEngineDownloadItem* download);
public slots:
class WebPageDownload : public QObject{
Q_OBJECT
public:
WebPageDownload(QObject *parent = nullptr);
private:
QWebEnginePage *page;
private slots:
void downloadRequested(QWebEngineDownloadItem* download);
public slots:
void download(const QUrl &url, const QString &filename = QString());
To copy to clipboard, switch view to plain text mode
Bookmarks