QT数据写出到指定文件夹下txt
作者:互联网
QT数据写出到指定文件夹下txt
代码:
void Timetable::coefficient_data_save()
{
QDir *temp = new QDir;
bool exist = temp->exists("../energyCalaulate//数据导出");
if(!exist)
{
temp->mkdir("../energyCalaulate//数据导出");
}
QDir *temp_2 = new QDir;
bool exist_2 = temp_2->exists("../energyCalaulate/数据导出//拟合系数");
if(!exist_2)
{
temp_2->mkdir("../energyCalaulate/数据导出//拟合系数");
}
for(int i=0;i<map_section_coefficient.size();++i)
{
QString section_name=vec_section_name[i];
QFile file(QString("../energyCalaulate/数据导出/拟合系数/%1").arg(section_name));
if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug() << "Open failed.";
return ;
}
QTextStream txtOutput(&file);
txtOutput<<"coefficient"<<"\n";
int coefficient_num=map_section_coefficient[i].size();
for(int j=0;j<coefficient_num;++j)
{
txtOutput<<QString::number(map_section_coefficient[i][j])<<"\n";
}
file.close();
}
}
标签:QT,..,导出,QDir,文件夹,exist,temp,txt,energyCalaulate 来源: https://blog.csdn.net/China_Rocky/article/details/112549956