头文件#include<QTextCodec>
在函数中添加。
out.setCodec(QTextCodec::codecForName("UTF-8"));//设定编码问题。
QString k="学号 ";
QString k1="姓名 ";
QString k2="班级 ";
QString k3="学院 ";//用"学院"会出现乱码
out<<k<<ui->lineEdit->text()<<"\n";
out<<k1<<ui->lineEdit_2->text()<<"\n";
out<<k2<<ui->lineEdit_3->text()<<"\n";
out<<k3<<ui->lineEdit_4->text()<<"\n";