经测试,好用,只不过是csv格式
void Widget::process()
{
QString fileName = QFileDialog::getSaveFileName(0, QObject::tr("Save File"), "", QObject::tr("file (*.csv)"));
if ("" == fileName)
{
return;
}
QTextCodec *code = 0;
code = QTextCodec::codecForName("gb18030");
if (0 == code)
{
return;
}
std::string fileBuffer = code->fromUnicode(fileName).data();
FILE *fileWrite = fopen(fileBuffer.c_str(), "w");
QString carryOut = "\n";
std::string content = code->fromUnicode(QString("Female") + "," + QString("Male") + "," + QString("NoMale") + carryOut +
QString().setNum(100) + "," + QString().setNum(101) + "," + QString().setNum(102)).data();
QFile file;
file.open(fileWrite, QIODevice::WriteOnly);
file.write(content.c_str(), qstrlen(content.c_str()));
file.close();
}
阅读(1922) | 评论(0) | 转发(0) |