PDA

View Full Version : Download file to QString



Chiggins
25th June 2010, 18:54
Hey all... What is the best way to download a file from HTTP or HTTPS, and turn the contents into a QString for I can manipulate it.

Also, when downloading the file, is there a difference when doing it if the protocol is HTTP or HTTPS?

Thanks :)

Lykurg
25th June 2010, 19:15
Also, when downloading the file, is there a difference when doing it if the protocol is HTTP or HTTPS?
The result is the same, but once it is transfered unencrypted and the other time it is encrypted (for the transfering only). See QNetworkAccessManager.

tbscope
25th June 2010, 19:16
Assuming you use QNetworkAccessManager:
Connect a slot to the readyRead signal, then use readAll to read the complete response (might take several passes to readyRead!).

When you have the bytearray, construct a qstring from this bytearray: QString(myByteArray)

Edit:
There is a difference between https and http at the protocol level. For you and me, it doesn't matter. Qt handles this behind the scenes.