Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Browser : how to download files
Qt 6.11 is out! See what's new in the release blog

Browser : how to download files

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yacinoben
    wrote on last edited by
    #1

    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 !

    raven-worxR 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi

      This example show how
      http://doc.qt.io/qt-5/qtnetwork-download-main-cpp.html

      look in
      void DownloadManager::downloadFinished(QNetworkReply *reply)

      1 Reply Last reply
      1
      • Y Offline
        Y Offline
        Yacinoben
        wrote on last edited by
        #3
        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

        mrjjM 1 Reply Last reply
        0
        • Y Yacinoben
          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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Yacinoben
          Ok. sounded like you wanted to download file. :)

          I dont know how your browser can give a link. sorry.

          1 Reply Last reply
          0
          • Y Yacinoben

            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 !

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @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)
            

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            1
            • Y Offline
              Y Offline
              Yacinoben
              wrote on last edited by
              #6

              @raven-worx said:

              content

              No, i use Qt WebEngine .

              raven-worxR 1 Reply Last reply
              0
              • Y Yacinoben

                @raven-worx said:

                content

                No, i use Qt WebEngine .

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by raven-worx
                #7

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

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                3
                • Y Offline
                  Y Offline
                  Yacinoben
                  wrote on last edited by Yacinoben
                  #8

                  I'm sorry to reply late, i don't see notification .
                  It works !! thank you for your help :)

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved