-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
37 lines (32 loc) · 938 Bytes
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>
#include <QLibraryInfo>
#include <QEvent>
#include <QComboBox>
#include <QString>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->comboBox->addItems(QStringList() << "ru_RU" << "en_US");
connect(ui->comboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
[=](const QString &str) {
qtLanguageTranslator.load(QString("QtLanguage_") + str);
qApp->installTranslator(&qtLanguageTranslator);
});
qtLanguageTranslator.load(QString("QtLanguage_") + QString("ru_RU"));
qApp->installTranslator(&qtLanguageTranslator);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}