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. how to download multi files in same time with multi Progress bar
Qt 6.11 is out! See what's new in the release blog

how to download multi files in same time with multi Progress bar

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.1k Views 2 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.
  • A Offline
    A Offline
    ARASHz4
    wrote on last edited by
    #1

    hi
    how to download multi files in same time & each download have a Progress bar

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Here's an example you can use as a starting point:

      #include <QApplication>
      #include <QProgressBar>
      #include <QNetworkAccessManager>
      #include <QNetworkRequest>
      #include <QNetworkReply>
      
      int main(int argc, char *argv[]) {
          QApplication a(argc, argv);
      
          QNetworkAccessManager nam;
      
          for( int i=0; i < 3; ++i) {
              auto reply = nam.get(QNetworkRequest(QUrl("http://whatever")));
              auto progress = new QProgressBar();
              progress->move(100, 100 * i);
              progress->show();
      
              QObject::connect(reply, &QNetworkReply::finished, progress, &QProgressBar::deleteLater);
              QObject::connect(reply, &QNetworkReply::downloadProgress, [=](qint64 bytes, qint64 total){
                  progress->setRange(0, total);
                  progress->setValue(bytes);
              });
          }
      
          return a.exec();
      }
      

      You can of course put the bars in some layout of some other widget, but I hope you get the idea.

      A 1 Reply Last reply
      3
      • Chris KawaC Chris Kawa

        Here's an example you can use as a starting point:

        #include <QApplication>
        #include <QProgressBar>
        #include <QNetworkAccessManager>
        #include <QNetworkRequest>
        #include <QNetworkReply>
        
        int main(int argc, char *argv[]) {
            QApplication a(argc, argv);
        
            QNetworkAccessManager nam;
        
            for( int i=0; i < 3; ++i) {
                auto reply = nam.get(QNetworkRequest(QUrl("http://whatever")));
                auto progress = new QProgressBar();
                progress->move(100, 100 * i);
                progress->show();
        
                QObject::connect(reply, &QNetworkReply::finished, progress, &QProgressBar::deleteLater);
                QObject::connect(reply, &QNetworkReply::downloadProgress, [=](qint64 bytes, qint64 total){
                    progress->setRange(0, total);
                    progress->setValue(bytes);
                });
            }
        
            return a.exec();
        }
        

        You can of course put the bars in some layout of some other widget, but I hope you get the idea.

        A Offline
        A Offline
        ARASHz4
        wrote on last edited by
        #3

        @Chris-Kawa thank you but i don't know how to use this code in my project : https://github.com/ARASHz4/Advanced_Downloader
        download is in class downloader.cpp
        Please help me i have no idea to do this.

        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