阅读背景:

QString转换为const char*(QFileDialog得到的QString文件路径(含中文)转换为fstream可用的const char*文件路径)以及解决Qt中文字符串乱码的一种思路

来源:互联网 

对于不含中文的文件路径,可用如下代码解决:

QString path=QFileDialog::getOpenFileName(this,QObject::tr("set filepath"));
	char*  ch;
	QByteArray ba =path.toLatin1();   
	ch=ba.data();
	ofstream test;
	test.open(ch);
	test<<"测试测试";
	test.close();QString path=QFileDi



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: