Qt实现字符串多语言支持,纯代码实现第一个应用程序

显示中文字符串,利用一个函数
Qobject::tr()
eg

//helloWorld.pro
QT += widgets	//和qt4兼容
//main.cpp
#include <QApplication>
#include <QDialog>
#include <QLabel>

int main(int argc, char* argv[])
{
    QApplication a(argc,argv);
    QDialog w;
    w.resize(400,300);
    QLabel label(&w);//对话框为标签的父窗口
    label.move(120,120);
    label.setText(QObject::tr("Hello world!你好世界"));
    w.show();
    return a.exec();
}

猜你喜欢

转载自blog.csdn.net/vict_wang/article/details/85338868