【发布时间】:2015-08-23 13:17:32
【问题描述】:
我正在使用 QRegExp 通过 grep 输出 QProcess 的最后一行
QString str (process->readAllStandardOutput());
现在我想阅读 str 的最后一行并在状态栏中显示 请问怎么才能只得到最后一行:(
【问题讨论】:
-
为什么要使用正则表达式?
str.mid(str.lastIndexOf('\n')+1)左右。 -
使用 rx.indexIn(line); 让它工作;
-
实际上我需要从字符串中获取一些特定信息,这就是我选择 QRegExp 的原因;)