std::istream to QByteArray



  • Can someone suggest me a way to convert a std::istream to QByteArray?
    Regards.



  • the question doesn't rally makes sense but anyway:

    // std::istream is;
    is.seekg (0, is.end);
    const int length = is.tellg();
    is.seekg (0, is.beg);
    QByteArray readBytes;
    readBytes.resize(length);
        is.read (readBytes.data(),length);
    


  • Many thanks for your quick help but seems to not work.
    After many time I have found a solution.

            std::istream &StreamIn= Session.receiveResponse(Res);
            QByteArray QBAByteIn;
            char Buffer[128];
            while (!StreamIn.eof()) {
                int BytesIn= StreamIn.read(Buffer, sizeof(Buffer)).gcount();
                QBAByteIn.append(Buffer, BytesIn);
            }
    
    

    Regards.


Log in to reply
 

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