Results 1 to 6 of 6

Thread: QTextStream help pls

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QTextStream help pls

    Hi,

    I am trying to parse a text file. There are a few constraints.

    1. If a line ends with "=", then the next line should also be read from the stream and should be added to the current line before sending it to the parse function.

    2. If the next line starts with " "(space) then the line should be added to current line and then should be sent to the parse function.

    Can someone please help me in this?
    Thanks a lot.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextStream help pls

    So what problems do you experience?

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextStream help pls

    How can I use QTextStream to read the lines satisfying the above conditions ?

    Thanks a lot

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextStream help pls

    Read lines one by one and check those conditions using for example QString::endsWith(). You'll probably have to use QIODevice::peek() to check the first character of the next line.

  5. The following user says thank you to wysota for this useful post:

    munna (16th May 2006)

  6. #5
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextStream help pls

    Another doubt:

    Since I use QTextStream to read the file, how will QFile know about the current position, so that peek() can be used?

    Thanks

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTextStream help pls

    Quote Originally Posted by munna
    Since I use QTextStream to read the file, how will QFile know about the current position, so that peek() can be used?
    QTextStream::device()
    J-P Nurmi

Similar Threads

  1. QTextStream : Remove a Line?
    By kaydknight in forum Qt Programming
    Replies: 7
    Last Post: 31st January 2011, 18:15
  2. reading Continously from QTextStream
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 2nd December 2008, 11:15
  3. when close QTextStream
    By mattia in forum Newbie
    Replies: 1
    Last Post: 24th November 2007, 13:17
  4. QTextStream + QFile issue
    By trueneo in forum Qt Programming
    Replies: 3
    Last Post: 22nd September 2007, 15:16
  5. Create QTextStream
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 17th June 2007, 20:25

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.