Results 1 to 2 of 2

Thread: QTcpSocket QDataStream QByteArray

  1. #1
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTcpSocket QDataStream QByteArray

    Hi.
    I'm trying to send some data through a QTcpSocket using QDataStream and a QByteArray.
    Qt Code:
    1. //QDataStream stream(mySocket);
    2. data = mySocket->readAll();
    3. QString dataText = QString(data);
    To copy to clipboard, switch view to plain text mode 
    Reading the data directly results in the string containing QVariant(QByteArray, "TEST")
    Qt Code:
    1. QDataStream stream(mySocket);
    2. stream >> data;
    3. QString dataText = QString(data);
    To copy to clipboard, switch view to plain text mode 
    Using QDataStream gives me an empty String
    Can anyone help me
    Me, Grimlock, not "nice dino". ME BASH BRAINS!

  2. #2
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket QDataStream QByteArray

    Ok I've figured it out. The problem was in the sending. As this was a testing program I forgot to send the data using QDataStream.
    Me, Grimlock, not "nice dino". ME BASH BRAINS!

Similar Threads

  1. QDataStream and QByteArray issue
    By sepehr in forum Qt Programming
    Replies: 13
    Last Post: 2nd April 2021, 16:41
  2. how QDataStream and QByteArray related
    By dognzhe in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2009, 08:45
  3. QDataStream and QTcpSocket
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 24th January 2009, 12:29
  4. QTcpSocket and QDataStream
    By December in forum Qt Programming
    Replies: 1
    Last Post: 22nd March 2008, 14:13
  5. Reading QByteArray from QDataStream Qt3.3
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 20:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.