- C/C++ code
问题描述:为什么我的qt程序无法把英文翻译成中文,其中编译和运行过程中都没有报错 为了什么?????我的翻译过程1在admin.pro文件里面加入TRANSLATIONS = fonts_zh.ts (admin是编译目录的名字)2# lupdate admin.pro3# linguist (这个在qt的bin目录下) (然后 1 open(fonts_zh.ts文件) --> 2 open -->resease 就会在打开的目录下生产 fonts_zh.qm)说明:经过第3步,我的fonts_zh.qm已经正确生成,应为在linguist工具中可以看到绿色的钩钩。4QTranslator translator;translator.load("fonts_zh");app.installTranslator(&translator);下面是我的源程序1 main.cpp#include "admin_system.h"//#include "login.h"#include <QApplication>#include <QtGui>int main(int argc, char *argv[]){ QApplication app(argc,argv); QTranslator translator; translator.load("fonts_zh"); app.installTranslator(&translator); AdministratorSystem *window = new AdministratorSystem(); window->show(); return app.exec();}2 admin_system.h#ifndef ADMIN_SYSTEM_H#define ADMIN_SYSTEM_H#include <QMainWindow>class QAction;class QMenu;class AdministratorSystem : public QMainWindow{ Q_OBJECTpublic: AdministratorSystem(); void createMenus(void); void createActions(void);private: QMenu *userManagementMenu; };#endif3 admin_system.cpp#include "admin_system.h"#include <QAction>#include <QtGui>AdministratorSystem::AdministratorSystem(void){ createActions(); createMenus(); resize(600, 480);}void AdministratorSystem::createActions(void){ }void AdministratorSystem::createMenus(void){ userManagementMenu = menuBar()->addMenu(tr("system management"));/*要翻译的只有这句*/}4 fonts_zh.ts<?xml version="1.0" encoding="utf-8"?><!DOCTYPE TS><TS version="2.0" language="zh_CN"><context> <name>AdministratorSystem</name> <message> <source>system management: </source> /*要翻译的只有这句*/ <translation>系统管理:</translation> </message></context></TS>
------解决方案--------------------
建议你多看看书。