1 #include<QtGui>
2 int main(int argc, char * argv[])
3 {
4 QApplication app(argc, argv);
5 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf-8"));
6 QWidget wgt;
7 wgt.setWindowTitle(QString::QString("我也有依靠"));
8 wgt.setGeometry(200, 200, 242, 150);
9 QLabel lbl(&wgt);
10 lbl.setText(QString::QString("我有依靠"));
11 lbl.move(50,50);
12 QLabel lblAlone;
13 lblAlone.setText("独行侠");
14 lblAlone.setGeometry(445, 200, 150, 150);
15 wgt.show();
16 lblAlone.show();
17 app.exec();
18 return 0;
19 }
标签也可以没有父元素