PDA

View Full Version : Qtextstream::readline()



dawn_to_dusk_
1st August 2008, 17:35
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...

jacek
2nd August 2008, 21:28
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?

dawn_to_dusk_
2nd August 2008, 22:25
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)

jacek
2nd August 2008, 23:34
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.


but still can't put it reading the data in reverse order properly.
If you have the positions, you can use QTextStream::seek().

dawn_to_dusk_
3rd August 2008, 17:58
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... :cool:


thnks