void MainWindow::saveFile()
{
QStringList lines;
lines.append("lines 1 ");
lines.append(QString::fromLocal8Bit("中文测试x"));
QFile file( "/root/program/text1.txt" );
if ( file.open( QIODevice::WriteOnly ) )
{
QTextStream stream( &file);
for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it )
stream << *it << "/n";
QString str;
//控件中文
stream << ui->textEdit->toPlainText() <<endl;
str = ui->textEdit->toPlainText();
stream <<str<<endl;
//写中文的方法
QString hint;
hint = hint.fromLocal8Bit("哈哈哈");
stream<<hint<<endl;
file.close();
}
}