赞
踩
今天读取txt类型的文件时,用QTextStream读取一行,对一行数据进行Split时发现,不同行有不同的分割符,不能确立单一的分割符,可用下面方式解决
- QRegExp Separator = QRegExp("\t|\n|\r\n|\r| |,|;");
-
- QString currentLine = stream.readLine();
- if (currentLine.isNull())
- {
- //end of file
- break;
- }
- if (currentLine.isEmpty() || currentLine.startsWith("//"))
- {
- //empty lines and comments are ignored
- continue;
- }
- //获取到的分割字符
- QStringList splitS = currentLine.split(Separator, QString::SkipEmptyParts);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。