国际化的英文表述为Internationalization,通常简写为I18N(首尾字母加中间的字符数),这种奇葩的缩写方式,让我想起了NBA球星“字母哥”。
下面看下Qt实现的动态语言切换效果。
一.效果
二.源码
QHSettingDialog.h
#ifndef QHSETTINGDIALOG_H
#define QHSETTINGDIALOG_H#include <QDialog>
#include <QEvent>namespace Ui {
class QHSettingDialog;
}class QHSettingDialog : public QDialog
{Q_OBJECTpublic:explicit QHSettingDialog(QWidget *parent = nullptr);~QHSettingDialog();enum Language{Chinese,EngLish};protected:void changeEvent(QEvent *event) override;private slots:void on_chineseRadioButton_clicked();void on_englishRadioButton_clicked();signals:void signalSwitchLanguage(Language language);private:void translateUI();private:Ui: