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. [SOLVED] Updater for my app
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Updater for my app

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.5k 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.
  • I Offline
    I Offline
    Imhotep
    wrote on last edited by
    #1

    I would like to implement a function that checks if there is an updated version of my app, and I took "this":http://www.bogotobogo.com/Qt/Qt5_QNetworkRequest_Http_File_Download.php as an example. Now I would like to ask: to create a progress bar that shows the progress of the download, I need to know the final size of the file and the current one. How can I do this?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You need to work with following classes and signals.

      QNetworkAccessManager
      QNetworkRequest
      QNetworkReply

      Look at following Signals of QNetworkReply.

      1. downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
      2. finished()

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Imhotep
        wrote on last edited by
        #3

        Following your example, I made this attempt:

        @
        //.h file

        ...
        void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
        ...
        @

        @
        //.cpp file (class constructor)

        QNetworkReply* reply = m_WebCtrl.get(QNetworkRequest(imageUrl));
        connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
        SLOT(downloadProgress(qint64,qint64)));
        @

        @
        //.cpp file (function declaration)

        void FileDownloader::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
        {
        qDebug() << bytesReceived << bytesTotal;
        }
        @

        But the IDE raises this error:

        QObject::connect: No such slot FileDownloader::downloadProgress(qint64,qint64)

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Did you define following function as slot under public slots section ?

          @void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);@

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • I Offline
            I Offline
            Imhotep
            wrote on last edited by
            #5

            Solved. Another question: If I wanted create a continually updated QLabels, which displays the bytes downloaded? A similar thing

            11 of 100 byets downloaded

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              You can do it. If it is single threaded application, you need to process the events using processEvents(..) method. If it multi threaded application, you can move the downloader code to worker thread and use the signal/slot mechanism to update from worker thread to main thread.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              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