Nominate our 2022 Qt Champions!

[Solved] How to read & write binary file from internet?

  • Dear all,

    I try to read & write binary file from internet using the following code

    @QNetworkReply *reply;
    QFile writeFile("test.exe");
    if ({
    QDataStream write(&writeFile;);
    write << reply->readAll();
    But, it add 4 extra bytes at the header of .exe file.
    I try to use QDataStream::writeRawData ( const char * s, int len )
    But how can I know the size of file from QNetworkReply *reply?

    Plz help
    Thanks to all

  • QNetworkReply inherits from QIODevice "size": That is what you are looking for. If this is not sufficient, you need to handle externally.

Log in to reply