-----------------以下是写的代码部分-------------
QString path = QFileDialog::getSaveFileName( QString::null, tr("工程文件(*.demo)"),this,tr("保存工程"),tr("保存工程"));
debug(path);
if(path.isEmpty())
{
return;
}
if(path.right(path.length() - path.find(".demo")).lower().compare(".demo") != 0)
{
path+=".demo";
}
debug(path);
QFile file(path);
if(file.exists())
{
qDebug(tr("已经存在同名的工程..."));
}
if(!file.open(IO_WriteOnly))
{
qDebug(tr("打开文件失败了..."));
}
QDataStream ds(&file);
ds<<tr("测试写文件成功")<<tr("over");
file.close();
------------------以下是读取的部分----------------
QString path = QFileDialog::getOpenFileName( QString::null, tr("工程文件(*.demo)"),this,tr("打开工程"),tr("打开工程"));
qDebug(path);
if(path.isEmpty())
{
return;
}
QFile file(path);
if(!file.open(IO_ReadOnly))
{
qDebug(tr("打开文件失败了... ..."));
}
QDataStream ds(&file);
QString demo;
ds>>demo;
debug(demo);
QMessageBox::information(this,demo,demo,"OK");
ds>>demo;
debug(demo);
QMessageBox::information(this,demo,demo,"OK");
请问,我写入的优中英文,读出来的为什么英文是乱码呢?