#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include <QObject>#include "ui_proga1.h"class MainWindow : public QMainWindow, Ui::MainWindow // <--------Наследуемся{ Q_OBJECTpublic: int m_rus; // объявляем глобальную переменную... MainWindow(QMainWindow* p = 0) : QMainWindow(p) { setupUi(this); connect(pushButton, SIGNAL(clicked()), this, SLOT(rasschet())); //подключаем кнопку рассчет connect(kn_about, SIGNAL(triggered()), this, SLOT(about())); // подключаем кнопку о программе connect(kn_help, SIGNAL(triggered()), this, SLOT(help())); //подключаем кнопку помощь connect(kn_author, SIGNAL(triggered()), this, SLOT(author())); //подключаем кнопку об авторе connect(kn_rus, SIGNAL(triggered()), this, SLOT(switchlang())); connect(kn_eng, SIGNAL(triggered()), this, SLOT(switchlang())); }public slots: void rasschet(); // создаем слот рассчет void about(); // создаем слот о программе void help(); // создаем слот помощь void author(); // создаем слот об авторе void swlang(); // создаем слот смены языка void switchlang();};#endif
#include <QtCore>#include <QTextCodec>#include <QtGui>#include <QTranslator>#include "proga1.h"............void MainWindow::switchlang(){ if (kn_rus -> isChecked()) { (m_rus << 1); kn_eng -> setCheckable(true); kn_eng -> setChecked(false); } if (kn_eng -> isChecked()) { (m_rus << 2); kn_rus -> setCheckable(true); kn_rus -> setChecked(false); }}void MainWindow::swlang(){ QTranslator translator; { switch(m_rus) case 1: //<=========== translator.load("rus.qm","."); break; case 2: //<=========== translator.load("eng.qm","."); break; } qApp->installTranslator(&translator);}
break statement not within loop or switchcase label '2' not within a switch statementbreak statement not within loop or switch
QTranslator translator; { switch(m_rus) case 1: //<=========== translator.load("rus.qm","."); break; case 2: //<=========== translator.load("eng.qm","."); break; }
(m_rus << 2);
C++ (Qt) QTranslator translator; switch(m_rus) { case 1: //<=========== translator.load("rus.qm","."); break; case 2: //<=========== translator.load("eng.qm","."); break; }
void MainWindow::switchlang(){ if (kn_rus -> isChecked()) { (m_rus = 1); kn_eng -> setCheckable(true); kn_eng -> setChecked(false); } if (kn_eng -> isChecked()) { (m_rus = 2); kn_rus -> setCheckable(true); kn_rus -> setChecked(false); }}
#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include <QObject>#include "ui_proga1.h"class MainWindow : public QMainWindow, Ui::MainWindow // <--------Наследуемся{ Q_OBJECTpublic: bool m_rus; MainWindow(QMainWindow* p = 0) : QMainWindow(p) { m_rus = true; // по умолчанию русский setupUi(this); .......... connect(kn_rus, SIGNAL(triggered()), this, SLOT(triggeredRussian())); // выбираем русский connect(kn_eng, SIGNAL(triggered()), this, SLOT(triggeredEnglish())); // выбираем английский }public slots: ........ void triggeredRussian(); void triggeredEnglish();};#endif
#include <QtCore>#include <QTextCodec>#include <QtGui>#include <QTranslator>#include "proga1.h"#include "proga1_about.h"#include "proga1_author.h"#include "proga1_help.h"#include "qm_files.h"#define tr QObject::tr.........void MainWindow::triggeredRussian(){ QTranslator translator; qDebug() << "Грузим русский перевод" ; m_rus = true; kn_eng->setChecked(false); translator.load("rus.qm","."); qApp->installTranslator(&translator);}void MainWindow::triggeredEnglish(){ QTranslator translator; qDebug() << "Грузим английский перевод" ; m_rus = false; kn_rus->setChecked(false); translator.load("eng.qm","."); qApp->installTranslator(&translator);}
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE TS><TS version="2.0" language="en_US" sourcelanguage="ru_RU"><context> <name>About</name> <message utf8="true"> <location filename="proga1_about.ui" line="26"/> <source>О программе</source> <translation>About program</translation> </message> <message utf8="true"> <location filename="proga1_about.ui" line="41"/> <source>Закрыть</source> <translation>Close</translation> </message> <message utf8="true"> <location filename="proga1_about.ui" line="54"/> <source>Программа переводит заданные с клавиатуры</source> <translation>The program translates the specified keyboard</translation> </message> <message utf8="true"> <location filename="proga1_about.ui" line="67"/> <source>секунды в вид ЧЧ:ММ:СС</source> <translation>seconds in the form HH:MM:SS</translation> </message></context><context> <name>Author</name> <message utf8="true"> <location filename="proga1_author.ui" line="35"/> <source>Об авторе</source> <translation>About author</translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="50"/> <source>Закрыть</source> <translation>Close</translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="63"/> <source>Автор программы: </source> <translation>Author program:</translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="76"/> <source>Мухин Денис Михайлович</source> <translation>Mukhin Denis Mikhailovich</translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="89"/> <source>студент группы ВМ-21</source> <translation>student group VM-21</translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="102"/> <source>2009 год</source> <translation>2009</translation> </message></context><context> <name>Help</name> <message utf8="true"> <location filename="proga1_help.ui" line="14"/> <source>Помощь</source> <translation>Help</translation> </message> <message utf8="true"> <location filename="proga1_help.ui" line="26"/> <source>Закрыть</source> <translation>Close</translation> </message></context><context> <name>MainWindow</name> <message utf8="true"> <location filename="proga1.ui" line="32"/> <source>Программа №1 :)</source> <translation>Programm #1</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="86"/> <source>Рассчитать</source> <translation>Calculate</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="99"/> <location filename="proga1.ui" line="196"/> <source>Выход</source> <translation>Quit</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="112"/> <source>Введите количество секунд</source> <translation>Enter the number of seconds</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="125"/> <source>Результат работы программы</source> <translation>The result of the program</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="141"/> <source>Файл</source> <translation>File</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="149"/> <source>Язык</source> <translation>Language</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="156"/> <source>Справка</source> <translation>Help</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="173"/> <source>Русский</source> <translation>Russian</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="181"/> <source>Английский</source> <translation>English</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="186"/> <source>О программе</source> <translation>About programm</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="191"/> <source>Об авторе</source> <translation>About author</translation> </message> <message> <location filename="proga1.ui" line="199"/> <source>Ctrl+Q</source> <translation>Ctrl+Q</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="204"/> <source>Помощь</source> <translation>Help</translation> </message> <message utf8="true"> <location filename="proga1.ui" line="209"/> <source>Открыть log-файл</source> <translation>Open log-file</translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source>Введенное количество секунд </source> <translation>The entered number of seconds</translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> соответствует </source> <translation>matches</translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> часам, </source> <translation>hours</translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> минутам, </source> <translation>minutes</translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> секундам</source> <translation>seconds</translation> </message></context></TS>
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE TS><TS version="2.0" language="ru_RU" sourcelanguage="en_US"><context> <name>About</name> <message utf8="true"> <location filename="proga1_about.ui" line="26"/> <source>О программе</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_about.ui" line="41"/> <source>Закрыть</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_about.ui" line="54"/> <source>Программа переводит заданные с клавиатуры</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_about.ui" line="67"/> <source>секунды в вид ЧЧ:ММ:СС</source> <translation></translation> </message></context><context> <name>Author</name> <message utf8="true"> <location filename="proga1_author.ui" line="35"/> <source>Об авторе</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="50"/> <source>Закрыть</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="63"/> <source>Автор программы: </source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="76"/> <source>Мухин Денис Михайлович</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="89"/> <source>студент группы ВМ-21</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_author.ui" line="102"/> <source>2009 год</source> <translation></translation> </message></context><context> <name>Help</name> <message utf8="true"> <location filename="proga1_help.ui" line="14"/> <source>Помощь</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1_help.ui" line="26"/> <source>Закрыть</source> <translation></translation> </message></context><context> <name>MainWindow</name> <message utf8="true"> <location filename="proga1.ui" line="32"/> <source>Программа №1 :)</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="86"/> <source>Рассчитать</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="99"/> <location filename="proga1.ui" line="196"/> <source>Выход</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="112"/> <source>Введите количество секунд</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="125"/> <source>Результат работы программы</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="141"/> <source>Файл</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="149"/> <source>Язык</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="156"/> <source>Справка</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="173"/> <source>Русский</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="181"/> <source>Английский</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="186"/> <source>О программе</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="191"/> <source>Об авторе</source> <translation></translation> </message> <message> <location filename="proga1.ui" line="199"/> <source>Ctrl+Q</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="204"/> <source>Помощь</source> <translation></translation> </message> <message utf8="true"> <location filename="proga1.ui" line="209"/> <source>Открыть log-файл</source> <translation></translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source>Введенное количество секунд </source> <translation></translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> соответствует </source> <translation></translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> часам, </source> <translation></translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> минутам, </source> <translation></translation> </message> <message> <location filename="proga1.cpp" line="28"/> <source> секундам</source> <translation></translation> </message></context></TS>
A?ocei ?onneee ia?aaia
void retranslateUi(QMainWindow *MainWindow) { MainWindow->setWindowTitle(QApplication::translate("MainWindow", "\320\237\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\260 \342\204\2261 :)", 0, QApplication::UnicodeUTF8)); kn_rus->setText(QApplication::translate("MainWindow", "\320\240\321\203\321\201\321\201\320\272\320\270\320\271", 0, QApplication::UnicodeUTF8)); kn_eng->setText(QApplication::translate("MainWindow", "\320\220\320\275\320\263\320\273\320\270\320\271\321\201\320\272\320\270\320\271", 0, QApplication::UnicodeUTF8)); kn_about->setText(QApplication::translate("MainWindow", "\320\236 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\265", 0, QApplication::UnicodeUTF8)); kn_author->setText(QApplication::translate("MainWindow", "\320\236\320\261 \320\260\320\262\321\202\320\276\321\200\320\265", 0, QApplication::UnicodeUTF8)); kn_exit->setText(QApplication::translate("MainWindow", "\320\222\321\213\321\205\320\276\320\264 (Ctrl+Q)", 0, QApplication::UnicodeUTF8)); kn_exit->setShortcut(QApplication::translate("MainWindow", "Ctrl+Q", 0, QApplication::UnicodeUTF8)); kn_help->setText(QApplication::translate("MainWindow", "\320\237\320\276\320\274\320\276\321\211\321\214 (F1)", 0, QApplication::UnicodeUTF8)); kn_help->setShortcut(QApplication::translate("MainWindow", "F1", 0, QApplication::UnicodeUTF8)); kn_log->setText(QApplication::translate("MainWindow", "\320\236\321\202\320\272\321\200\321\213\321\202\321\214 log-\321\204\320\260\320\271\320\273", 0, QApplication::UnicodeUTF8));#ifndef QT_NO_WHATSTHIS spinBox->setWhatsThis(QString());#endif // QT_NO_WHATSTHIS pushButton->setText(QApplication::translate("MainWindow", "\320\240\320\260\321\201\321\201\321\207\320\270\321\202\320\260\321\202\321\214", 0, QApplication::UnicodeUTF8)); pushButton_2->setText(QApplication::translate("MainWindow", "\320\222\321\213\321\205\320\276\320\264", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("MainWindow", "\320\222\320\262\320\265\320\264\320\270\321\202\320\265 \320\272\320\276\320\273\320\270\321\207\320\265\321\201\321\202\320\262\320\276 \321\201\320\265\320\272\321\203\320\275\320\264", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("MainWindow", "\320\240\320\265\320\267\321\203\320\273\321\214\321\202\320\260\321\202 \321\200\320\260\320\261\320\276\321\202\321\213 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\321\213", 0, QApplication::UnicodeUTF8)); menu->setTitle(QApplication::translate("MainWindow", "\320\244\320\260\320\271\320\273", 0, QApplication::UnicodeUTF8)); menu_2->setTitle(QApplication::translate("MainWindow", "\320\257\320\267\321\213\320\272", 0, QApplication::UnicodeUTF8)); menu_3->setTitle(QApplication::translate("MainWindow", "\320\241\320\277\321\200\320\260\320\262\320\272\320\260", 0, QApplication::UnicodeUTF8)); } // retranslateUi