Results 1 to 2 of 2

Thread: QWebEngineProfile downloadRequested() not invoking

  1. #1
    Join Date
    Mar 2016
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

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

    mainwindow.ccp

    Qt Code:
    1. WebPageDownload *webPageDownload = new WebPageDownload(this);
    2. 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

    Qt Code:
    1. WebPageDownload::WebPageDownload(QObject *parent){
    2. page = new QWebEnginePage(parent);
    3. connect(page->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
    4. }
    5.  
    6. void WebPageDownload::download(const QUrl &url, const QString &filename){
    7. qDebug()<<"download called";
    8. //this should emit QWebEngineProfile::downloadRequested
    9. page->download(url, filename);
    10. }
    11.  
    12. void WebPageDownload::downloadRequested(QWebEngineDownloadItem* download) {
    13. qDebug()<<"Download request invoked";
    14. }
    To copy to clipboard, switch view to plain text mode 
    webpagedownload.h

    Qt Code:
    1. class WebPageDownload : public QObject{
    2. Q_OBJECT
    3.  
    4. public:
    5. WebPageDownload(QObject *parent = nullptr);
    6.  
    7. private:
    8. QWebEnginePage *page;
    9.  
    10. private slots:
    11. void downloadRequested(QWebEngineDownloadItem* download);
    12.  
    13. public slots:
    14. void download(const QUrl &url, const QString &filename = QString());
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QWebEngineProfile downloadRequested() not invoking

    This looks correct but just to be sure check the return value of the connect() call.

    In any case also have a look at QNetworkAccessManager if you don't need to display the web content.

    Cheers,
    _

Similar Threads

  1. QWebEngineProfile question.
    By ayanda83 in forum Qt Programming
    Replies: 1
    Last Post: 11th December 2016, 12:50
  2. invoking qml from cpp
    By Coy0ty in forum Qt Quick
    Replies: 1
    Last Post: 27th October 2012, 10:01
  3. Invoking another application
    By Qting in forum Qt Programming
    Replies: 5
    Last Post: 6th February 2012, 17:35
  4. qmake not invoking uic?
    By Regenlied in forum Newbie
    Replies: 7
    Last Post: 9th August 2011, 17:07
  5. Invoking a browser...???
    By deepusrp in forum Newbie
    Replies: 4
    Last Post: 12th June 2007, 18:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.