我做的是一个使用折线图读取txt文件的数据
txt文件中第一列是时间
第二列是温度
第三列是速度
第四列是湿度
我中间按照空格隔开
column.at(0) 在我的理解是读取第一列
为什么column.at(1) column.at(2) 可以读到图像上
column.at(3) 读不到图像上呢
求解答
QFile outFile("C:/Users/yemu/Desktop/1111.txt");
if(!outFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug()<<"canot open!";
}
QTextStream stream(&outFile);
//分别声明接受各列变量的QStringList
QStringList stepStrArr,var2StrArr;
QStringList column;//如果声明到循环内程序崩掉!!!
while(!stream.atEnd()){
QString wholeLine=stream.readLine();
qDebug()<<"wholeLine"<<wholeLine;
//过滤掉文本中的#行,和“variables”行
if (wholeLine.startsWith("#") ||wholeLine.startsWith("variables"))
continue;
//以“ ”为分隔符将每一行划分成多列
column=wholeLine.split(" ",QString::SkipEmptyParts);
stepStrArr.append(column.at(0));//接受column[0]的值
var2StrArr.append(column.at(2));//接受column[2]的值