Results 1 to 2 of 2

Thread: QDataStream doesn't work as expected

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QDataStream doesn't work as expected

    I have this sample code:
    Qt Code:
    1. QDataStream *newDataSrteam;
    2.  
    3. quint32 tag;
    4. tag = 0x00;
    5. newDataSrteam = new QDataStream(&ba, QIODevice::WriteOnly | QIODevice::Unbuffered);
    6. newDataSrteam->setByteOrder(QDataStream::LittleEndian);
    7.  
    8. int i = 0;
    9. while(i++<10)
    10. {
    11. ba.clear();
    12. *newDataSrteam << (quint32)tag++;
    13. printf("%s\n", ba.toHex().data());
    14. }
    To copy to clipboard, switch view to plain text mode 
    and running I get the following output:
    Qt Code:
    1. 00000000
    2. 0000000001000000
    3. 303030303030303002000000
    4. 30303030303030300200000003000000
    5. 3030303030303030020000000300000004000000
    6. 303030303030303002000000030000000400000005000000
    7. 33303330333033303330333033303330303230303030303006000000
    8. 3330333033303330333033303330333030323030303030300600000007000000
    9. 333033303330333033303330333033303032303030303030060000000700000008000000
    10. 33303330333033303330333033303330303230303030303006000000070000000800000009000000
    To copy to clipboard, switch view to plain text mode 

    I wonder what is wrong with my code...
    what is happening? It seem that be is never cleared...

    thanks
    Last edited by mastupristi; 16th June 2010 at 14:46.

Similar Threads

  1. Example in Qt labs doesn't work
    By matko in forum Newbie
    Replies: 1
    Last Post: 19th November 2009, 18:59
  2. setFont doesn't work
    By DadaLee in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 11th August 2008, 06:29
  3. setWindowModality doesn't work
    By dude in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2008, 14:11
  4. QRegExp doesn't seem to work as it should
    By thomaspu in forum Qt Programming
    Replies: 3
    Last Post: 21st December 2007, 07:49
  5. Connection doesn't work
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2007, 12:09

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
  •  
Qt is a trademark of The Qt Company.