-1

I build a QT project on CentOS 7.I have changed the /etc/locale.conf to 'zh_CN.gb2312'.

when I open QFiledialog without 'DontUseNativeDialog' to chose a file , the file name displays in the dialog occurs messy code, even I add these following code in the main():

QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));  
QTextCodec::setCodecForLocale(QTextCodec::codecForName("GB2312"));  
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));  

How to fix this problem ? My app will not only support English or Chinese , It should compatible with all the languages within the linux . The QT must can check the system language automatically, but how to ?

Thanks .

cyberpunker
  • 49
  • 1
  • 1
  • 7

1 Answers1

0

This may be the secret :
when I was in the UTF-8 environment, and name a file , the file name is stored in utf-8 style . when I change to CGB2312 environment,the utf-8 is interpret in GB2312 by glibc , so the messy code emerge. The messy code Not noly in QT QFiledialog, but so in the bshell . The QT native GUI window and the bshell both base on glibc ,right ?

May be the gnome treat this specially , it is smart enough to interpret the encoding of the file name , so in gnome file browse toolkit, the name shows right under both the UTF-8 and GB2312 environment .

cyberpunker
  • 49
  • 1
  • 1
  • 7