Results 1 to 5 of 5

Thread: Qtextstream::readline()

  1. #1
    Join Date
    Aug 2008
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Qtextstream::readline()

    hi!

    i've experiencing some adversities using Qtextstream as i'm looking to read a file line by line, witch i can do as expected, but i can't just go to a specific line or reverse the reading order.

    like if i was reading line 1,2,3,4 and then i wanted to read line 3,2,1.


    if someone could help...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtextstream::readline()

    Quote Originally Posted by dawn_to_dusk_ View Post
    but i can't just go to a specific line or reverse the reading order.
    That's because it's a stream, not an array of lines.

    How big is that file?

  3. #3
    Join Date
    Aug 2008
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qtextstream::readline()

    about 4megabytes


    i've half solved it using a linked list that stores the position on the file for each new line, but still can't put it reading the data in reverse order properly.

    i think tomorow i'll manage it. Then i'll post the solution 8)

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtextstream::readline()

    Quote Originally Posted by dawn_to_dusk_ View Post
    i've half solved it using a linked list that stores the position on the file for each new line,
    It's a good approach, especially for big files. You can read smaller files (like yours) into a QStringList.

    Quote Originally Posted by dawn_to_dusk_ View Post
    but still can't put it reading the data in reverse order properly.
    If you have the positions, you can use QTextStream::seek().

  5. #5
    Join Date
    Aug 2008
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qtextstream::readline()

    If you have the positions, you can use QTextStream::seek().

    yup, but there is something that is not allowing the reverse playback in the code and today is sunday...


    thnks

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.