qt - read a text file to QStringList -
i have text file. need read qstringlist. there no line seperators. mean each line in text file in new line. there anyway can this?
i assume every line should separate string in list. use qtextstream::readline() in cycle , on each step append returned value qstringlist. this:
qstringlist stringlist; qfile textfile; //... (open file reading, etc.) qtextstream textstream(&textfile); while (true) { qstring line = textstream.readline(); if (line.isnull()) break; else stringlist.append(line); }
Comments
Post a Comment