qt和eclipse安装在windows上,用eclispe开发qt应用程序。
程序源代码如下:
#include <QtGui>
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QTextCodec *codec = QTextCodec::codecForName("UTF8");
QTextCodec::setCodecForTr(codec);
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);
QApplication a(argc, argv);
HelloWorldQt w;
QWidget * pWidget=new QWidget;
QLabel label(pWidget);
char *string = "中文和English混和字符串!";
label.setText(codec->toUnicode(string));
pWidget->show();
return a.exec();
}
红字部分改成GBK或GB2312程序运行就出错,windows提示信息如下:
问题事件名称: APPCRASH
应用程序名: HelloWorldQt.exe
应用程序版本: 0.0.0.0
应用程序时间戳: 4bd14bd0
故障模块名称: QtCored4.dll
故障模块版本: 4.3.2.0
故障模块时间戳: 4bd03d45
异常代码: c0000005
异常偏移: 00136a5f
OS 版本: 6.1.7600.2.0.0.256.1
区域设置 ID: 2052
其他信息 1: 0a9e
其他信息 2: 0a9e372d3b4ad19135b953a78882e789
其他信息 3: 0a9e
其他信息 4: 0a9e372d3b4ad19135b953a78882e789
请问是什么原因,如何解决?