Results 1 to 5 of 5

Thread: QDataStream reading into QString

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows
    Thanks
    9
    Thanked 27 Times in 27 Posts

    Default Re: QDataStream reading into QString

    what strings actually insteads?
    a life without programming is like an empty bottle

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: QDataStream reading into QString

    You did not write a QString but instead a
    Qt Code:
    1. const char *
    To copy to clipboard, switch view to plain text mode 
    This
    Qt Code:
    1. outStream << QString("The beginning of a series of numbers");
    To copy to clipboard, switch view to plain text mode 
    should work. Or you could change the type you are trying to read out of the stream.

  3. #3
    Join Date
    Jan 2006
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDataStream reading into QString

    Quote Originally Posted by Codepoet
    You did not write a QString but instead a
    Qt Code:
    1. const char *
    To copy to clipboard, switch view to plain text mode 
    This
    Qt Code:
    1. outStream << QString("The beginning of a series of numbers");
    To copy to clipboard, switch view to plain text mode 
    should work. Or you could change the type you are trying to read out of the stream.
    This worked just fine. It's interesting that they didn't mention this in the example that trolltech has in the 3.3 documentation for QDataStream.

    http://doc.trolltech.com/3.3/qdatastream.html#details

    Quote Originally Posted by Docs
    Example (write binary data to a stream):

    QFile file( "file.dat" );
    file.open( IO_WriteOnly );
    QDataStream stream( &file ); // we will serialize the data into the file
    stream << "the answer is"; // serialize a string
    stream << (Q_INT32)42; // serialize an integer


    Example (read binary data from a stream):

    QFile file( "file.dat" );
    file.open( IO_ReadOnly );
    QDataStream stream( &file ); // read the data serialized from the file
    QString str;
    Q_INT32 a;
    stream >> str >> a; // extract "the answer is" and 42
    The end of time is reached around the year 8000, by which time we expect Qt to be obsolete.

    -Note in QDate documentation. It's nice that Qt has been able to predict when the world will end.

Similar Threads

  1. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53
  2. Replies: 8
    Last Post: 27th August 2007, 15:45
  3. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  4. Reading QByteArray from QDataStream Qt3.3
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 20:23
  5. QDataStream >> QString
    By smalls in forum Qt Programming
    Replies: 2
    Last Post: 17th January 2006, 22:14

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.