Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    [Solved] Cancelable dowloading dialog?

    Mobile and Embedded
    2
    6
    3046
    Loading More Posts
    • 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
      zolakt last edited by

      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 Reply Quote 0
      • D
        DenisKormalev last edited by

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

        1 Reply Last reply Reply Quote 0
        • Z
          zolakt last edited by

          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 Reply Quote 0
          • D
            DenisKormalev last edited by

            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 Reply Quote 0
            • Z
              zolakt last edited by

              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 Reply Quote 0
              • Z
                zolakt last edited by

                got it working
                forgot to derive myClass from QObject

                thanks a lot for your help

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post