Important: Please read the Qt Code of Conduct -

QWebEngineProfile downloadRequested() not invoking

  • 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.


    WebPageDownload *webPageDownload = new WebPageDownload(this);
    webPageDownload->download("", "file.cvs");


    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";


    class WebPageDownload : public QObject{
    WebPageDownload(QObject *parent = nullptr);
    QWebEnginePage *page;
    private slots:
    void downloadRequested(QWebEngineDownloadItem* download);
    public slots:
    void download(const QUrl &url, const QString &filename = QString());

  • Hello @bandito

    I tested your code on Qt 5.12.2 and everthing is working well with a single change.

    webPageDownload->download(QString(""), "file.cvs");

    Because QUrl cannot use const char* variable as parameter and don't auto convert to QString.

    First of all, what Qt and MSVC versions are you using ?

  • This may sound weird but I play around with it some more and it was calling another method. I changed some of the code in that method and then downloadRequested got called. I guess something went squirrelly in the QT engine.

Log in to reply