QString aaa = QObject::tr(QT_TR_NOOP("Hello"));int MainFunc( int argc, char *argv[] ){ QApplication app(argc, argv); QTranslator translator; bool is = translator.load("appcenter_ru.qm", app.applicationDirPath()); QApplication::installTranslator(&translator); QLabel lbl(aaa); lbl.show(); return app.exec();}
QString aaa;void initdd(){ aaa = QObject::tr("Hello");}int MainFunc( int argc, char *argv[] ){ QApplication app(argc, argv); DDDDD ddd(&app); initdd(); QPushButton button(aaa); bool c1 = QObject::connect(&button, SIGNAL(pressed()), &ddd, SLOT(ChangeLang())); button.show(); return app.exec();}
class DDDDD : public QObject{ Q_OBJECTpublic: DDDDD(QObject *parent = 0); DDDDD(QApplication* app_); ~DDDDD();public slots: void ChangeLang();private: QTranslator translator; QApplication* app;};void DDDDD::ChangeLang(){ bool is = translator.load("appcenter_ru.qm", app->applicationDirPath()); app->installTranslator(&translator);}