Unsolved Why can't it display Chinese?
-
Hello everyone,
Could somebody help me?
I create a QMainWindow. I set 'windowTitle' to some Chinese in the Designer. It works.
But if I QTextCodec::setCodecForLocale();, it doesn't work.
Please give me some advice.
Thank you in advance. -
@Qingshui-Kong said in Why can't it display Chinese?:
Please give me some advice
Please provide more information/show the code...
-
If I change the code to
The result changes to
-
Could somebody give me some advice?
-
Nobody would like to give me any advice?
I think maybe I should give up. -
@Qingshui-Kong Did you try to set window title using https://doc.qt.io/qt-5/qwidget.html#windowTitle-prop to see whether that makes a difference?
-
@jsulm
Thank you very much.
But I think it doesn't work.
If I don't set code for locale
The result is
If I set code for locale
The result changes to
-
@Qingshui-Kong Why do you use fromLocal8Bit?! Chinese can't be represented as 8bit encoding. Remove fromLocal8Bit and make sure your source code files are stored as UTF-8 (should be default in QtCreator).
-
@jsulm
Thanks a lot.
My source code files are stored as GBK. I forgot the reason why I didn't use UTF-8. But there must be some problems. But I can't remember it.After I store source code files as UTF-8, if I don't set code for locale, it works. If I set code for locale, it still dosen't work.
-
@Qingshui-Kong Did you remove fromLocal8Bit?
-
@Qingshui-Kong
Try this macroQStringLiteral
like:setWindowTitle(QStringLiteral("小工具"));
It helps me a lot.
-
@jsulm
Yes, I did. -
@Bonnie
Thanks.
I will try it.