[Solved] Cancelable dowloading dialog?
-
wrote on 8 Nov 2010, 18:56 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?
-
wrote on 8 Nov 2010, 19:38 last edited by
You should implement cancellation by yourself. It will be not hard. Just close the connection and collect garbage.
-
wrote on 8 Nov 2010, 20:13 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
-
wrote on 8 Nov 2010, 20:44 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.
-
wrote on 8 Nov 2010, 21:51 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)' -
wrote on 8 Nov 2010, 22:17 last edited by
got it working
forgot to derive myClass from QObjectthanks a lot for your help
1/6