Multiple QTextStreams use readline to read the same QFile, and the obtained QString is empty
-
I use QFile to open a csv file stored locally in xlsx. In the way of QIODevice::ReadOnly | QIODevice::Text, then define a QTextStream object, use readline to read four lines of data, each time the pos() of the file is 24, 51, 78, 105, because the first line has Chinese, so it is different from the incremented value later, but immediately after defining the second QTextStream object, the value returned by pos after using readline is 37, and then defining another one, the same operation, the returned value is 22, my data is basically this Kind of "2021/11/17,11:01:15,41,1,", if many QTextStream objects are defined, the data read will appear empty
-
Well then don't define multiple text streams, right? Each operation on a file will move the current position in the QFile object, so from that perspective what you describe seems OK. Maybe share the relevant piece of code and we'll be able to help then.