当前位置:网站首页>QT dynamic translation of Chinese and English languages
QT dynamic translation of Chinese and English languages
2022-04-23 03:20:00 【Happinessคิดถึง】
**
Update time :2021-04-21
**
The interface program is suitable for users in many countries , There will be a choice of language .
design sketch :

The translation is divided into several parts :
1. First determine the position of the string you want to translate
2. stay pro Add... To the document :TRANSLATIONS = chinese.ts
Open the compiler you are using cmd, Switch to project path . And implement :lupdate.exe xxx.pro obtain ts file

3. Use linguist.exe Open generated ts file , And add the Chinese you want to translate .
4. After translation , choice – file – Also published as – Save to local qm File can .

Code using :
The header file :
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QDebug>
#include <QTranslator> // internationalization
#include <QLibraryInfo> // internationalization
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private slots:
void on_comboBox_currentIndexChanged(int index);
private:
Ui::Widget *ui;
QTranslator tran;
};
#endif // WIDGET_H
cpp file :
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
// Load translation qm file
void Widget::on_comboBox_currentIndexChanged(int index)
{
if(ui->comboBox->currentIndex()==1)
{
tran.load(":/lang/chinese.qm");
qApp->installTranslator(&tran);
}else
{
qApp->removeTranslator(&tran);
}
ui->retranslateUi(this);
}
Here I just translate and use . There are lots of holes in it . I'll update it later .
I've only done Chinese and English translation here . If there are other languages that need corresponding qm File for translation . Here still suggest that you should learn English well . Purring .
版权声明
本文为[Happinessคิดถึง]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220623156500.html
边栏推荐
- MySQL索引详解【B+Tree索引、哈希索引、全文索引、覆盖索引】
- Queue storage and circular queue
- MySQL grouping query rules
- OLED multi-level menu record
- Blazor University (12) - component lifecycle
- Fight leetcode again (290. Word law)
- Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
- oracle 查询外键含有逗号分隔的数据
- 12.<tag-链表和常考点综合>-lt.234-回文链表
- 数据挖掘系列(3)_Excel的数据挖掘插件_估计分析
猜你喜欢

2022年P气瓶充装培训试题及模拟考试

How does Microsoft solve the problem of multiple programs on PC side -- internal implementation
![Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]](/img/1a/a22b4a35d3c083438d0f766a5ecb08.png)
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]

MySQL之explain关键字详解

Blazor University (12) - component lifecycle

TCP three handshakes and four waves

OLED多级菜单记录

Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800

This new feature of C 11, I would like to call it the strongest!
![[mock data] fastmock dynamically returns the mock content according to the incoming parameters](/img/1e/c4aad49d16fb21a19865ba75128e43.png)
[mock data] fastmock dynamically returns the mock content according to the incoming parameters
随机推荐
Configuration table and page information automatically generate curd operation page
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
The most understandable life cycle of dependency injection
LoadRunner - performance testing tool
js 中,为一个里面带有input 的label 绑定事件后在父元素绑定单机事件,事件执行两次,求解
批量下载文件----压缩后再下载
MySql关键字GROUP_CONCAT,组合连接查询
TCP three handshakes and four waves
Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
Yes Redis using distributed cache in NE6 webapi
为什么BI对企业这么重要?
Batch download of files ---- compressed and then downloaded
ThreadLocal 测试多线程变量实例
超好用的【通用Excel导入功能】
Preview of converting doc and PDF to SWF file
socket編程 send()與 recv()函數詳解
WinForm allows the form form to switch between the front and active states
Find the number of leaf nodes of binary tree
月薪10k-20k都无法回答的事务问题,你会吗?