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. QTcpSocket read QByteArray
Forum Update on Monday, May 27th 2025

QTcpSocket read QByteArray

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.4k Views
  • 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.
  • T Offline
    T Offline
    tucnak
    wrote on last edited by
    #1

    Hi. I need to read from socket QByteArray, qUncompress() it and pick three QStrings from it.
    My pseudo-code:
    @
    QDataStream in(socket);
    in.setVersion(QDataStream::Qt_4_0);
    if (blockSize == 0) {
    if (sock->bytesAvailable() < (int)sizeof(quint16))
    return;
    in >> blockSize;
    }
    if (sock->bytesAvailable() < blockSize)
    return;
    blockSize = 0;
    QByteArray data;
    in >> data;
    qUncompress(data);
    QTextStream text(&data);
    text >> str >> str2 >> str3;
    @

    How can I do it?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Do you see any problems when using an implementation based on your pseudo-code?

      Vote the answer(s) that helped you to solve your issue(s)

      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