IPS
IPS

Reputation: 81

QT reading file line by line

I need to read the contents of a file line by line.

Sample.txt:

#define <tabspace> temp <tabspace> 10

Code:

QFile file("D:\Sample.txt");
QTextStream in(&file);
QString str_Line = in.readLine();

str_Line contains #definetemp10

How to read the line with including the tab spaces? can any one please help me out?

Upvotes: 0

Views: 2297

Answers (1)

user4773247
user4773247

Reputation:

Combine the multiple whitespaces into a single white space. Use QString::simplified() or QString::trimmed().

In your code add the below line,

QString str_Line = in.readLine();
str_Line.trimmed();//
str_Line.simplified();//

Upvotes: 1

Related Questions