[Solved] Request speed in QNAM
-
Hi everyone,
I want to know the speed of the HTTP get request made to some link using QNetworkAccessManager.
I have checked QNetworkReply api and was not able to find such function.
But what I found is this [1] but there is not mention anywhere after how much time, this signal will be emitted. So that I would be able to know the download speed.
Does anybody knows this time?
Or any other better solution to get download speed.
[1] http://doc.qt.io/qt-5/qnetworkreply.html#downloadProgressThanks,
Ashish Bansal -
pownloadProgress is not emitted at constant intervals.
Use "QElapsedTimer":http://doc.qt.io/qt-5/qelapsedtimer.html. Start it when you make the request and use "restart":http://doc.qt.io/qt-5/qelapsedtimer.html#restart in the downloadProgress handler to obtain amount of time passed between these signals. Speed is then the amount of data (obtained from bytesReceived parameter of the downloadProgress) divided by the time from the timer. Make sure to get the units right. -
[quote author="Chris Kawa" date="1419793610"]pownloadProgress is not emitted at constant intervals.
Use "QElapsedTimer":http://doc.qt.io/qt-5/qelapsedtimer.html. Start it when you make the request and use "restart":http://doc.qt.io/qt-5/qelapsedtimer.html#restart in the downloadProgress handler to obtain amount of time passed between these signals. Speed is then the amount of data (obtained from bytesReceived parameter of the downloadProgress) divided by the time from the timer. Make sure to get the units right.[/quote]Thanks Chris!!