############################################################################## Makefile for building: Project# Generated by qmake (2.01a) (Qt 4.6.0) on: ?? 5. ??? 00:07:26 2009# Project: Project.pro# Template: app# Command: c:\qt\4.6.0\bin\qmake.exe -spec ..\Qt\4.6.0\mkspecs\win32-g++ -win32 -o Makefile Project.pro#############################################################################first: debuginstall: debug-installuninstall: debug-uninstallMAKEFILE = MakefileQMAKE = c:\qt\4.6.0\bin\qmake.exeDEL_FILE = delCHK_DIR_EXISTS= if not existMKDIR = mkdirCOPY = copy /yCOPY_FILE = $(COPY)COPY_DIR = xcopy /s /q /y /iINSTALL_FILE = $(COPY_FILE)INSTALL_PROGRAM = $(COPY_FILE)INSTALL_DIR = $(COPY_DIR)DEL_FILE = delSYMLINK = DEL_DIR = rmdirMOVE = moveCHK_DIR_EXISTS= if not existMKDIR = mkdirSUBTARGETS = \ debug \ releasedebug: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debugdebug-make_default: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debug debug-make_first: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debug firstdebug-all: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debug alldebug-clean: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debug cleandebug-distclean: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debug distcleandebug-install: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debug installdebug-uninstall: $(MAKEFILE).Debug FORCE $(MAKE) -f $(MAKEFILE).Debug uninstallrelease: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Releaserelease-make_default: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Release release-make_first: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Release firstrelease-all: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Release allrelease-clean: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Release cleanrelease-distclean: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Release distcleanrelease-install: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Release installrelease-uninstall: $(MAKEFILE).Release FORCE $(MAKE) -f $(MAKEFILE).Release uninstallMakefile: Project.pro ../Qt/4.6.0/mkspecs/win32-g++/qmake.conf ../Qt/4.6.0/mkspecs/qconfig.pri \ ../Qt/4.6.0/mkspecs/features/qt_functions.prf \ ../Qt/4.6.0/mkspecs/features/qt_config.prf \ ../Qt/4.6.0/mkspecs/features/exclusive_builds.prf \ ../Qt/4.6.0/mkspecs/features/default_pre.prf \ ../Qt/4.6.0/mkspecs/features/win32/default_pre.prf \ ../Qt/4.6.0/mkspecs/features/debug.prf \ ../Qt/4.6.0/mkspecs/features/debug_and_release.prf \ ../Qt/4.6.0/mkspecs/features/default_post.prf \ ../Qt/4.6.0/mkspecs/features/win32/default_post.prf \ ../Qt/4.6.0/mkspecs/features/win32/exceptions_off.prf \ ../Qt/4.6.0/mkspecs/features/static.prf \ ../Qt/4.6.0/mkspecs/features/warn_on.prf \ ../Qt/4.6.0/mkspecs/features/qt.prf \ ../Qt/4.6.0/mkspecs/features/win32/thread.prf \ ../Qt/4.6.0/mkspecs/features/moc.prf \ ../Qt/4.6.0/mkspecs/features/win32/windows.prf \ ../Qt/4.6.0/mkspecs/features/win32/stl_off.prf \ ../Qt/4.6.0/mkspecs/features/win32/rtti_off.prf \ ../Qt/4.6.0/mkspecs/features/resources.prf \ ../Qt/4.6.0/mkspecs/features/uic.prf \ ../Qt/4.6.0/mkspecs/features/yacc.prf \ ../Qt/4.6.0/mkspecs/features/lex.prf \ ../Qt/4.6.0/mkspecs/features/include_source_dir.prf \ c:/Qt/4.6.0/lib/qtmaind.prl \ c:/Qt/4.6.0/lib/QtGui.prl \ c:/Qt/4.6.0/lib/QtCore.prl $(QMAKE) -spec ..\Qt\4.6.0\mkspecs\win32-g++ -win32 -o Makefile Project.pro..\Qt\4.6.0\mkspecs\qconfig.pri:..\Qt\4.6.0\mkspecs\features\qt_functions.prf:..\Qt\4.6.0\mkspecs\features\qt_config.prf:..\Qt\4.6.0\mkspecs\features\exclusive_builds.prf:..\Qt\4.6.0\mkspecs\features\default_pre.prf:..\Qt\4.6.0\mkspecs\features\win32\default_pre.prf:..\Qt\4.6.0\mkspecs\features\debug.prf:..\Qt\4.6.0\mkspecs\features\debug_and_release.prf:..\Qt\4.6.0\mkspecs\features\default_post.prf:..\Qt\4.6.0\mkspecs\features\win32\default_post.prf:..\Qt\4.6.0\mkspecs\features\win32\exceptions_off.prf:..\Qt\4.6.0\mkspecs\features\static.prf:..\Qt\4.6.0\mkspecs\features\warn_on.prf:..\Qt\4.6.0\mkspecs\features\qt.prf:..\Qt\4.6.0\mkspecs\features\win32\thread.prf:..\Qt\4.6.0\mkspecs\features\moc.prf:..\Qt\4.6.0\mkspecs\features\win32\windows.prf:..\Qt\4.6.0\mkspecs\features\win32\stl_off.prf:..\Qt\4.6.0\mkspecs\features\win32\rtti_off.prf:..\Qt\4.6.0\mkspecs\features\resources.prf:..\Qt\4.6.0\mkspecs\features\uic.prf:..\Qt\4.6.0\mkspecs\features\yacc.prf:..\Qt\4.6.0\mkspecs\features\lex.prf:..\Qt\4.6.0\mkspecs\features\include_source_dir.prf:c:\Qt\4.6.0\lib\qtmaind.prl:c:\Qt\4.6.0\lib\QtGui.prl:c:\Qt\4.6.0\lib\QtCore.prl:qmake: qmake_all FORCE @$(QMAKE) -spec ..\Qt\4.6.0\mkspecs\win32-g++ -win32 -o Makefile Project.proqmake_all: FORCEmake_default: debug-make_default release-make_default FORCEmake_first: debug-make_first release-make_first FORCEall: debug-all release-all FORCEclean: debug-clean release-clean FORCEdistclean: debug-distclean release-distclean FORCE -$(DEL_FILE) Makefiledebug-mocclean: $(MAKEFILE).Debug $(MAKE) -f $(MAKEFILE).Debug moccleanrelease-mocclean: $(MAKEFILE).Release $(MAKE) -f $(MAKEFILE).Release moccleanmocclean: debug-mocclean release-moccleandebug-mocables: $(MAKEFILE).Debug $(MAKE) -f $(MAKEFILE).Debug mocablesrelease-mocables: $(MAKEFILE).Release $(MAKE) -f $(MAKEFILE).Release mocablesmocables: debug-mocables release-mocablesFORCE:$(MAKEFILE).Debug: Makefile$(MAKEFILE).Release: Makefile
..........if lang=ru {- <property name="text"> <string>Программа переводит заданные с клавиатуры</string> </property> </widget>- <widget class="QLabel" name="label_2">- <property name="geometry">- <rect> <x>20</x> <y>30</y> <width>231</width> <height>16</height> </rect> </property>- <property name="text"> <string>секунды в вид ЧЧ:ММ:СС</string> }if lang=en {- <property name="text"> <string>The program translates the specified keyboard</string> </property> </widget>- <widget class="QLabel" name="label_2">- <property name="geometry">- <rect> <x>20</x> <y>30</y> <width>231</width> <height>16</height> </rect> </property>- <property name="text"> <string>seconds in the form HH:MM:SS</string> }.............
e
#ifndef GET_LANGUAGE_H#define GET_LANGUAGE_H#include <QFile>extern char LANG[1];void getLanguage() { QFile file("language.txt"); file.open(QIODevice::ReadOnly); file.read(LANG,1); // read 1 byte ---> LANG[0]}#endif // GET_LANGUAGE_H
#ifndef SET_LANGUAGE_H#define SET_LANGUAGE_H#include <QFile>extern char LANG[1];void setLanguage() { QFile file("language.txt"); file.open(QIODevice::WriteOnly); file.write(LANG,1); // write 1 byte}#endif // SET_LANGUAGE_H
#include <QtGui>#include <QtPlugin>#include "proga1.h"#include "get_language.h" char LANG[1]; int main(int argc, char *argv[]){ QApplication app(argc, argv);//==================== getLanguage(); qDebug() << LANG[0];//==================== MainWindow w; w.show(); return app.exec();}
... menu_3->addAction(kn_log);//================================================ extern char LANG[1]; if (LANG[0]== 'e') { pushButton->setText("Translate"); pushButton_2->setText("Close"); menu_2->setTitle("Language"); kn_rus->setText("Russian"); kn_eng->setText("English"); // OTHER } else retranslateUi(MainWindow);//================================================
... 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(setRus())); connect(kn_eng, SIGNAL(triggered()), this, SLOT(setEng()));...
#include <QtCore>#include <QTextCodec>#include <QtGui>#include "proga1.h"#include "proga1_about.h"#include "proga1_author.h"#include "proga1_help.h"#define tr QObject::tr#include "set_language.h"extern char LANG[1]; void MainWindow::rasschet(){int iS, oS, notH, notM; //Объявление переменныхfloat oH, oM; //Объявление переменныхconst int SiH=3600, SiM=60;QString inSec, outHr, outMin, outSec;textEdit->clear();inSec = spinBox->text(); //ВводqDebug() << inSec;iS = inSec.toInt();qDebug() << iS;//ВычислениеoH = (iS / SiH); //Количество часовnotH = iS - (oH * SiH); //Убираем количество часовoM = (notH / SiM); //Количество минутnotM = notH - (oM * SiM); //Убираем количество минутoS = notM; //Оставшееся число равно количеству секундif (LANG[0]=='r'){ QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251")); textEdit->setText(tr("Введенное количество секунд ")+QString::number(iS) + tr(" соответствует ") + QString::number(oH) + tr(" часам, " ) + QString::number(oM) + tr(" минутам, ") + QString::number(oS) + tr(" секундам"));}else {qDebug() << LANG[0] << "English";}}void MainWindow::about(){QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));qDebug() << "MainWindow::about";qDebug() << this->isModal();// Главное окно - модальное// Сделаем его немодальным, т.е. разблокируем дочерние виджеты для вводаthis->setWindowModality(Qt::NonModal);MyAbout *myabout = new MyAbout;myabout->show();}void MainWindow::help(){QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));qDebug() << "MainWindow::help";qDebug() << this->isModal();this->setWindowModality(Qt::NonModal);MyHelp *myhelp = new MyHelp;myhelp->show();}void MainWindow::author(){QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));qDebug() << "MainWindow::author";qDebug() << this->isModal();this->setWindowModality(Qt::NonModal);MyAuthor *myauthor = new MyAuthor;myauthor->show();}void MainWindow::setRus(){LANG[0] = 'r';setLanguage();}void MainWindow::setEng(){LANG[0] = 'e';setLanguage();}
#ifndef DATEBIR_H#define DATEBIR_H#include <QtGui> // For qDebug() ;namespace Ui{ class DateBir;}class DateBir : public QMainWindow{ Q_OBJECTpublic: DateBir(QWidget *parent = 0); ~DateBir();public slots: void detectDay(bool );private: Ui::DateBir *ui; qint8 m_date; // <==============};
#include "datebir.h"#include "ui_datebir.h"void DateBir::detectDay(bool blablabla){ qDebug() << "in slot detectDate()"; m_date=3; // <=============== ui->label->setText(QString::number(m_date));}DateBir::DateBir(QWidget *parent) : QMainWindow(parent), ui(new Ui::DateBir){ ui->setupUi(this); connect(ui->btn1, SIGNAL(clicked(bool)), SLOT(detectDay(bool) ));}DateBir::~DateBir(){ delete ui;}
C:/Pr1/proga1.cpp:65: error: prototype for 'void MainWindow::switchLanguage(int)' does not match any in class 'MainWindow'C:/Pr1/proga1.h:24: error: candidate is: void MainWindow::switchLanguage()
#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include <QObject>#include "ui_proga1.h"class MainWindow : public QMainWindow, Ui::MainWindow // <--------Наследуемся{ Q_OBJECTpublic: 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(changed()), this, SLOT(switchLanguage())); connect(kn_eng, SIGNAL(changed()), this, SLOT(switchLanguage())); }public slots: void rasschet(); // создаем слот рассчет void about(); // создаем слот о программе void help(); // создаем слот помощь void author(); // создаем слот об авторе void switchLanguage(); // создаем слот смены языка (это я добавил)};#endif
#include <QtCore>#include <QTextCodec>#include <QtGui>#include "proga1.h"#include "proga1_about.h"#include "proga1_author.h"#include "proga1_help.h"#define tr QObject::trvoid MainWindow::rasschet(){int iS, oS, notH, notM; //Объявление переменныхfloat oH, oM; //Объявление переменныхconst int SiH=3600, SiM=60;QString inSec, outHr, outMin, outSec;textEdit->clear();inSec = spinBox->text(); //ВводqDebug() << inSec;iS = inSec.toInt();qDebug() << iS;//ВычислениеoH = (iS / SiH); //Количество часовnotH = iS - (oH * SiH); //Убираем количество часовoM = (notH / SiM); //Количество минутnotM = notH - (oM * SiM); //Убираем количество минутoS = notM; //Оставшееся число равно количеству секундQTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));textEdit->setText(tr("Введенное количество секунд ")+QString::number(iS) + tr(" соответствует ") + QString::number(oH) + tr(" часам, " ) + QString::number(oM) + tr(" минутам, ") + QString::number(oS) + tr(" секундам"));}void MainWindow::about(){QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));qDebug() << "MainWindow::about";qDebug() << this->isModal();// Главное окно - модальное// Сделаем его немодальным, т.е. разблокируем дочерние виджеты для вводаthis->setWindowModality(Qt::NonModal);MyAbout *myabout = new MyAbout;myabout->show();}void MainWindow::help(){QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));qDebug() << "MainWindow::help";qDebug() << this->isModal();// Главное окно - модальное// Сделаем его немодальным, т.е. разблокируем дочерние виджеты для вводаthis->setWindowModality(Qt::NonModal);MyHelp *myhelp = new MyHelp;myhelp->show();}void MainWindow::author(){QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));qDebug() << "MainWindow::author";qDebug() << this->isModal();// Главное окно - модальное// Сделаем его немодальным, т.е. разблокируем дочерние виджеты для вводаthis->setWindowModality(Qt::NonModal);MyAuthor *myauthor = new MyAuthor;myauthor->show();}// Это добавленоvoid MainWindow::switchLanguage (int n){ QTranslator translator; switch(n) { case RUSSIAN: translator.load("rus.qm","."); break; case ENGLISH: translator.load("eng.qm","."); break; } app->installTranslator(&translator);}
#include <QApplication>#include <QTranslator>#include <QtPlugin> Q_IMPORT_PLUGIN(qjpeg) Q_IMPORT_PLUGIN(qgif) Q_IMPORT_PLUGIN(qkrcodecs)#include "proga1.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); MainWindow w; w.show(); return app.exec();}
...void MainWindow::switchLanguage (int n){ qDebug() << n; //<=========== QTranslator translator; switch(n) { case RUSSIAN: //<=========== translator.load("rus.qm","."); break; case ENGLISH: //<===========
// Это добавленоvoid MainWindow::switchLanguage (int n){ qDebug() << n; // смотрим n <============/* QTranslator translator; switch(n) { case RUSSIAN: translator.load("rus.qm","."); break; case ENGLISH: translator.load("eng.qm","."); break; } app->installTranslator(&translator); */}
connect(kn_rus, SIGNAL(changed()), this, SLOT(swlang())); connect(kn_eng, SIGNAL(changed()), this, SLOT(swlang()));