windows下QT使用ifstream读取含中文路径的txt文件

#include 
#include
#include
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
 QCoreApplication a(argc, argv);
 QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));
 QString qq="C:\\Users\\威\\Desktop\\a.txt";
 char*  ch;
 QByteArray ba = qq.toLocal8Bit();  // must
 ch=ba.data();
 cout< 
  
ifstream in(ch);
if (!in)
{
cout << "erro" < 
  
}
 
  
for(string str;getline(in,str);){
   cout< 
  
 
}
    return a.exec();
}
 
 

你可能感兴趣的:(qt,windows)