Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. std::istream to QByteArray
Forum Updated to NodeBB v4.3 + New Features

std::istream to QByteArray

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by
    #1

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

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      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);
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        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.

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved