Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved] Cancelable dowloading dialog?
QtWS25 Last Chance

[Solved] Cancelable dowloading dialog?

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 2 Posters 3.4k Views
  • 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.
  • Z Offline
    Z Offline
    zolakt
    wrote on last edited by
    #1

    Hi,

    I'm developing an app for Maemo. The app downloads some audio files from the server.
    As the data downloads I would like to show the loading dialog.
    Also I'd like it to have a "Cancel" button, which will stop the downloading if clicked.

    Is there any way to bind the downloading directly to the dialog, or do I have to implement threading myself?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      You should implement cancellation by yourself. It will be not hard. Just close the connection and collect garbage.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zolakt
        wrote on last edited by
        #3

        Any example maybe?
        Currently I'm only sending a request to QNetworkAccessManager.
        I'm running an event loop to ensure synchronous reply.

        Other thing, is there any way to display progress data of downloading. Example. 0.2/1.3mb

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          To get progress info you can use signal
          @
          void QNetworkReply::downloadProgress ( qint64 bytesReceived, qint64 bytesTotal )
          @

          For cancellation you can use either
          @
          void QNetworkReply::abort ()
          @
          or
          @
          void QNetworkReply::close ()
          @

          Read about them in Assistant, they are slightlty different.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zolakt
            wrote on last edited by
            #5

            I'm having problems connecting the QNetworkReply signal.

            My code:
            @
            QNetworkReply *reply = manager->post(request, data);
            QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
            this, SLOT(downProg(qint64,qint64)))
            @

            Gives an error:
            no matching function to call to 'QObject:connect(QNetworkReply*&, const char*, MyClass* const, const char*)'
            candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt:ConnectionType)'

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zolakt
              wrote on last edited by
              #6

              got it working
              forgot to derive myClass from QObject

              thanks a lot 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