首页 > 代码库 > Hello,Qt!

Hello,Qt!

 1 #include <QApplication>
 2 #include <QLabel>
 3 #include <QtCore/QTextCodec>
 4 #include <Qtgui/QDialog>
 5 #include <Qtextcodec.h>
 6 
 7 
 8 int main(int argc, char **argv)
 9 {
10     QApplication app(argc, argv);
11 
12     QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
13     QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
14     QLabel *label = new QLabel();
15     label->setText(QString::fromUtf8("<h2><i>Hello!</i>"
16                                      "<font color = red>你好!</font></h2>" ));
17     label->show();
18 
19     return app.exec();
20 }