|
QFile cmdInfoTmp("cmdInfo.tmp");
if (cmdInfoTmp.open(QIODevice::ReadOnly)) {
QTextStream stream( &cmdInfoTmp );
QString line;
while ( !stream.atEnd() ) {
line = stream.readLine();
if(line.contains("成功创建")){
QMessageBox::information(this, tr("info"), tr("have found the string"));
}else{
QMessageBox::information(this, tr("info"), tr("haven't' found the string"));
}
}
cmdInfoTmp.close();
}
/*
QString test("测试");
if(test.contains("测")){
QMessageBox::information(this, tr("info"), tr("haven found the string test"));
}
*/
cmdInfo.tmp里面的内容如下:
项 {f2a062b0-ead1-11de-93dd-08002703cdb6} 成功创建。
就是从文件中读出的汉字在用QString 的contains判断的时候无效,有没有方法判断中文字符? 或者我写的不对?但是下面的字符串测试正常啊。还是因为Qt的字符编码和win下的GB2312不是匹配的? |
|