我用Qtdesigner 生成了个工程。一个PUSHBOX,点击之后一个MESSAGELABEL显示出汉字。其中用
下面的代码来进行中文显示,
-
- #include "hello.h"
- #include <qlabel.h>
- #include <qtextcodec.h>
- HelloForm::HelloForm( QWidget* parent, const char* name, WFlags fl):
- HelloBaseForm(parent, name, fl)
- {
- }
- HelloForm::~HelloForm()
- {
- }
- void HelloForm::SayHello()
- {
- QCString str = "中文";
- QTextCodec *codec = QTextCodec::codecForName("GBK");
- QString strText = codec->toUnicode(str);
-
- MessageLabel->setText(strText);
- //QString str = str.fromLocal8Bit("中文");
- //MessageLabel->setText(str);
- }
程序编译通过,可是执行到QString strText = codec->toUnicode(str);一句时,REDHAT9发生 Abort错误。
在开发板上同样是这个结果,
换用注释掉的语句,程序可执行通过,可是显示出来的字符为乱码(不是方块)。
这是什么原因呢,请各位老师同仁指导,实验室一干人等翘首企盼。
如果我说得不清楚,请您提出来,我马上响应。
再次感谢您的热心。