动态切换语言

动态切换语言
connect(langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLang(int)) ); // 载入不同的语言包
void WizarDialog::changeLang( int langIndex ) {
    QTranslator *translator = new QTranslator(qApp);
    switch( langCombo->currentIndex() ){
        case 0:
            translator->load(QString("./language/pt_BR"));
            break;
        case 1:
            translator->load(QString("./language/en_US"));
            break;
        case 2:
            translator->load(QString("./language/zh_CN"));
        default:
            break;
    }
    qApp->installTranslator( translator );
    this->initGUI();
} // initGUI() 中会有大量的tr函数
 
void WizarDialog::initGUI() { this->setWindowTitle(tr("RTA04W")); /* ...... */ }

你可能感兴趣的:(动态切换语言)