Results 1 to 8 of 8

Thread: Read/Write from QTextStream

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jul 2008
    Posts
    4
    Qt products
    Qt4
    Thanks
    1

    Default Re: Read/Write from QTextStream

    Thanks. I missed that seek() function completely. Implementing seek() to the QByteArray case seems to be working.

    example:

    Qt Code:
    1. QString buffer = "funny world";
    2.  
    3. QByteArray array;
    4. array.append(buffer);
    5. QTextStream out(&array,QIODevice::ReadWrite);
    6.  
    7. //out.pos() == 0
    8. out << "hello"; //"hello" overwrites "funny"
    9.  
    10. out.seek(0); // set position to 0
    11.  
    12. QString string;
    13. QString string2;
    14.  
    15. // stream == "hello world"
    16. // QTextStream reads into strings word by word delimited by space
    17. out >> string; // == "hello"
    18. out >> string2; // == "world"
    To copy to clipboard, switch view to plain text mode 
    Last edited by tonde; 31st July 2008 at 11:21.

Similar Threads

  1. QTextStream : Remove a Line?
    By kaydknight in forum Qt Programming
    Replies: 7
    Last Post: 31st January 2011, 19:15
  2. when close QTextStream
    By mattia in forum Newbie
    Replies: 1
    Last Post: 24th November 2007, 14:17
  3. Create QTextStream
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2007, 21:25
  4. reading from QTextStream
    By matyi52 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 14th December 2006, 08:26
  5. QTextStream capture stdout from xsltParseStylesheetFile
    By patrik08 in forum Qt Programming
    Replies: 9
    Last Post: 25th June 2006, 12:24

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.