QFile and specific line
How to read specific line to QString? I know how to do this with reading whole text file, but i wanna read text from specific file. I have that code:
file->open(QIODevice::ReadOnly | QIODevice::Text);
line = file->readLine();
tab[i] = line.toInt();
...and that's ok. It works. I have some of that from doc, but how to get to for example ... 12th line? They are all numbers.
I guess, i have to put loop which reading file (and move pointer forward), but i don't know what condition could it be. My prevorious tryings were fails so I'm looking forward for answer...
You gave the answer right yourselef: create a loop and read until the place you need.
If you don't know the additional conditions, how could we know?
Do the text documents use some type of pre formated text, like markup?
You can not only read the nth line of a text file, not unless you have additional information. One help could be every line having the same number of characters. If you know that each line has, say, 20 characters (exactly!), you can just skip to the correct position in the file.
If you want to read 'N'th line of a file with randomly generated text, you have only the option of reading line by line. If you know any character size upto that location you could probably do a relative jump.