Results 1 to 4 of 4

Thread: QDataStream writing wrong values

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2012
    Posts
    17
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default QDataStream writing wrong values

    Hi

    I wish to write something onto a data file. I thought of using QDataStream, but it tens to give me wrong output.

    Qt Code:
    1. QFile file("file.dat");
    2. file.open(QIODevice::WriteOnly);
    3. QDataStream out(&file);
    4. out.setByteOrder(QDataStream::LittleEndian);
    5. //out << QString("the answer is"); // serialize a string
    6. int x = 54;
    7. out << (qint32)x;
    8. out.device()->close();
    To copy to clipboard, switch view to plain text mode 

    I was expecting an output of 54. Itself it shouwing me its char value = 6; even with other numbers.

    Please let me know how to address this problem

    Thanks

    Regards
    Alok
    Last edited by alok9871; 21st March 2013 at 03:25.

Similar Threads

  1. qbytearray qdatastream qfile writing/reading
    By pekal in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2012, 21:51
  2. How to convert string hex values to its real binary values?
    By AttilaPethe in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2012, 22:47
  3. QextSerialPort reading error: wrong values
    By Lawand in forum Qt Programming
    Replies: 9
    Last Post: 6th May 2009, 19:29
  4. QDataStream
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 23rd August 2006, 14:40
  5. QDataStream
    By frankoz in forum Qt Programming
    Replies: 1
    Last Post: 1st March 2006, 07:18

Tags for this Thread

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.