Qt把数据写入文件
QString splitFileName = pcdFiePath; splitFileName = splitFileName.replace(".pcd",".txt"); QFile splitDataFile(splitFileName); if (!splitDataFile.open(QIODevice::WriteOnly)) { //qDebug() << "pcd file can't open..."; QString logStr2 = QString(u8"写入文件无法打开!"); qDebug() << "" << logStr2; return pcd_geode; } QTextStream fileWriteObj(&splitDataFile); QString lineHeaderStr = QString("") .append(QString("id\t")) .append(QString("level\t")) .append(QString("s_x\t")) .append(QString("s_y\t")) .append(QString("s_z\t")) .append(QString("e_x\t")) .append(QString("e_y\t")) .append(QString("e_z\n")) ; fileWriteObj << lineHeaderStr; for (int k = 0; k < list_all_space.size(); k++) { PCDSpace* indexSpace = list_all_space.at(k); QString lineDataStr = QString("") .append(QString::number(space_id)).append(QString("\t")) .append(QString::number(spaceLevel)).append(QString("\t")) .append(QString::number(s_x)).append(QString("\t")) .append(QString::number(s_y)).append(QString("\t")) .append(QString::number(s_z)).append(QString("\t")) .append(QString::number(e_x)).append(QString("\t")) .append(QString::number(e_y)).append(QString("\t")) .append(QString::number(e_z)).append(QString("\n")) ; fileWriteObj << lineDataStr; } splitDataFile.flush(); splitDataFile.close();
####################