Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946
QFile and specific line
roosaw last edited by
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...
goetz last edited by
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?
zester last edited by
Do the text documents use some type of pre formated text, like markup?
andre last edited by
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.
Darryl DSouza last edited by
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.