[Solved] Cancelable dowloading dialog?

  • 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?

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

  • 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

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

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

    Read about them in Assistant, they are slightlty different.

  • 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)'

  • got it working
    forgot to derive myClass from QObject

    thanks a lot for your help

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.