有下面一段代码,编译运行后却是乱码
- #include <QApplication>
 - #include <QHBoxLayout>
 - #include <QSlider>
 - #include <QSpinBox>
 - #include <QLabel>
 - #include <QObject>
 - //#include <QTextCodec> 
 - int main(int argc, char *argv[])
 - {    
 -     QApplication app(argc, argv);
 -     QWidget *window = new QWidget;
 -     window->setWindowTitle(QObject::trUtf8("输入你的年龄"));
 -     QSpinBox *spinBox = new QSpinBox;
 -     QSlider *slider = new QSlider(Qt::Horizontal);
 -     spinBox->setRange(0, 130);
 -     slider->setRange(0, 130);
 -     QObject::connect(spinBox, SIGNAL(valueChanged(int)),
 -                                      slider, SLOT(setValue(int)));
 -     QObject::connect(slider, SIGNAL(valueChanged(int)),
 -                                      spinBox, SLOT(setValue(int)));
 -                                         
 -     spinBox->setValue(35);
 -     QHBoxLayout *layout = new QHBoxLayout;
 -     layout->addWidget(spinBox);
 -     layout->addWidget(slider);
 -     
 -     QLabel* label=new QLabel(QObject::trUtf8("你的年龄:"));
 -     
 -     QVBoxLayout* mainLayout=new QVBoxLayout;
 -     mainLayout->addWidget(label);
 -     mainLayout->addLayout(layout);
 -     
 -     window->setLayout(mainLayout);
 -     window->resize(300,50);
 -     window->show();
 -     return app.exec();
 - }    
 
  
 于是我把QObject::trUtf8换成了QObject::tr,又加了一行QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF8")); 
还是乱码,
但我把"UTF8" 换成 "GB2312"  是正常的 
 这该怎么解释啊
[ 此帖被午小夜在2010-04-08 00:44重新编辑 ]