#include <QApplication>#include "ui_proga1.h"#include "proga1.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); Ui::MainWindow mainWindow; QMainWindow *w = new QMainWindow; mainWindow.setupUi(w); w->show(); return app.exec();}void MainWindow::rasschet(){далее описание}
void MainWindow::rasschet()
void rasschet()
void::rasschet()
#include <QApplication>#include "ui_proga1.h"#include "proga1.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); Ui::MainWindow mainWindow; QMainWindow *w = new QMainWindow; mainWindow.setupUi(w); w->show(); return app.exec();}void::rasschet(){//Объявление переменныхint iS, oH, oM, oS, notH, notM;const int SiH=3600, SiM=60;QString inSec, outHr, outMin, outSec, Buffer;QSpinBox *spinBox = new QSpinBox;QTextEdit *textEdit = new QTextEdit;//ВводinSec = spinBox->text();iS = inSec.toInt();//Вычисление//Количество часовoH = (iS / SiH);//Убираем количество часовnotH = iS - (oH * SiH);//Количество минутoM = (notH / SiM);//Убираем количество минутnotM = notH - (oM * SiM);oS = notM;//Вывод результатаBuffer.sprintf("Введенное количество секунд %1f соответствует %1f часам, %1f минутам и %1f секундам \n", &iS, &oH, &oM, &oS);textEdit->setText(Buffer);}
#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include <QObject>#include "ui_proga1.h"class MainWindow : public QMainWindow{ Q_OBJECTpublic: MainWindow();private slots: void rasschet();private: Ui::MainWindow ui;};MainWindow::MainWindow(){ ui.setupUi( this ); connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(rasschet()));}#endif
####################################################################### Automatically generated by qmake (2.01a) ?? 30. ??? 15:08:10 2009######################################################################TEMPLATE = appTARGET = DEPENDPATH += .INCLUDEPATH += .# InputHEADERS += proga1.hFORMS += proga1.ui proga1_about.ui proga1_author.ui proga1_help.uiSOURCES += main.cppRESOURCES += resources.qrc
/********************************************************************************** Form generated from reading ui file 'proga1.ui'**** Created: Fri 30. Oct 15:48:49 2009** by: Qt User Interface Compiler version 4.4.3**** WARNING! All changes made in this file will be lost when recompiling ui file!********************************************************************************/#ifndef UI_PROGA1_H#define UI_PROGA1_H#include <QtCore/QVariant>#include <QtGui/QAction>#include <QtGui/QApplication>#include <QtGui/QButtonGroup>#include <QtGui/QLabel>#include <QtGui/QMainWindow>#include <QtGui/QMenu>#include <QtGui/QMenuBar>#include <QtGui/QPushButton>#include <QtGui/QSpinBox>#include <QtGui/QStatusBar>#include <QtGui/QTextEdit>#include <QtGui/QWidget>QT_BEGIN_NAMESPACEclass Ui_MainWindow{public: QAction *action_4; QAction *action_5; QAction *action_6; QAction *action_7; QAction *action_Ctrl_Q; QWidget *centralwidget; QSpinBox *spinBox; QTextEdit *textEdit; QPushButton *pushButton; QPushButton *pushButton_2; QLabel *label; QLabel *label_2; QStatusBar *statusbar; QMenuBar *menubar; QMenu *menu; QMenu *menu_2; QMenu *menu_3; void setupUi(QMainWindow *MainWindow) { if (MainWindow->objectName().isEmpty()) MainWindow->setObjectName(QString::fromUtf8("MainWindow")); MainWindow->setWindowModality(Qt::ApplicationModal); MainWindow->setEnabled(true); MainWindow->resize(385, 294); MainWindow->setMinimumSize(QSize(385, 294)); MainWindow->setMaximumSize(QSize(385, 294)); action_4 = new QAction(MainWindow); action_4->setObjectName(QString::fromUtf8("action_4")); action_4->setCheckable(true); action_4->setChecked(true); action_5 = new QAction(MainWindow); action_5->setObjectName(QString::fromUtf8("action_5")); action_5->setCheckable(true); action_6 = new QAction(MainWindow); action_6->setObjectName(QString::fromUtf8("action_6")); action_7 = new QAction(MainWindow); action_7->setObjectName(QString::fromUtf8("action_7")); action_Ctrl_Q = new QAction(MainWindow); action_Ctrl_Q->setObjectName(QString::fromUtf8("action_Ctrl_Q")); centralwidget = new QWidget(MainWindow); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); spinBox = new QSpinBox(centralwidget); spinBox->setObjectName(QString::fromUtf8("spinBox")); spinBox->setGeometry(QRect(50, 40, 161, 22)); spinBox->setMaximum(10000000); textEdit = new QTextEdit(centralwidget); textEdit->setObjectName(QString::fromUtf8("textEdit")); textEdit->setGeometry(QRect(50, 110, 301, 71)); textEdit->setReadOnly(true); pushButton = new QPushButton(centralwidget); pushButton->setObjectName(QString::fromUtf8("pushButton")); pushButton->setGeometry(QRect(250, 40, 101, 21)); pushButton_2 = new QPushButton(centralwidget); pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); pushButton_2->setGeometry(QRect(160, 210, 75, 23)); label = new QLabel(centralwidget); label->setObjectName(QString::fromUtf8("label")); label->setGeometry(QRect(50, 20, 151, 16)); label_2 = new QLabel(centralwidget); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setGeometry(QRect(50, 90, 151, 16)); MainWindow->setCentralWidget(centralwidget); statusbar = new QStatusBar(MainWindow); statusbar->setObjectName(QString::fromUtf8("statusbar")); MainWindow->setStatusBar(statusbar); menubar = new QMenuBar(MainWindow); menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setGeometry(QRect(0, 0, 385, 22)); menu = new QMenu(menubar); menu->setObjectName(QString::fromUtf8("menu")); menu_2 = new QMenu(menubar); menu_2->setObjectName(QString::fromUtf8("menu_2")); menu_3 = new QMenu(menubar); menu_3->setObjectName(QString::fromUtf8("menu_3")); MainWindow->setMenuBar(menubar); QWidget::setTabOrder(spinBox, pushButton); QWidget::setTabOrder(pushButton, textEdit); QWidget::setTabOrder(textEdit, pushButton_2); menubar->addAction(menu->menuAction()); menubar->addAction(menu_2->menuAction()); menubar->addAction(menu_3->menuAction()); menu->addAction(action_6); menu->addAction(action_7); menu->addAction(action_Ctrl_Q); menu_2->addAction(action_4); menu_2->addAction(action_5); retranslateUi(MainWindow); QObject::connect(pushButton_2, SIGNAL(clicked()), MainWindow, SLOT(close())); QObject::connect(action_Ctrl_Q, SIGNAL(triggered()), MainWindow, SLOT(close())); QMetaObject::connectSlotsByName(MainWindow); } // setupUi 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)); action_4->setText(QApplication::translate("MainWindow", "\320\240\321\203\321\201\321\201\320\272\320\270\320\271", 0, QApplication::UnicodeUTF8)); action_5->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)); action_6->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)); action_7->setText(QApplication::translate("MainWindow", "\320\236\320\261 \320\260\320\262\321\202\320\276\321\200\320\265", 0, QApplication::UnicodeUTF8)); action_Ctrl_Q->setText(QApplication::translate("MainWindow", "\320\222\321\213\321\205\320\276\320\264", 0, QApplication::UnicodeUTF8)); 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\237\320\276\320\274\320\276\321\211\321\214", 0, QApplication::UnicodeUTF8)); } // retranslateUi};namespace Ui { class MainWindow: public Ui_MainWindow {};} // namespace UiQT_END_NAMESPACE#endif // UI_PROGA1_H
C++ (Qt)#include <QApplication>#include "proga1.h" int main(int argc, char *argv[]){ QApplication app(argc, argv); QMainWindow *w = new QMainWindow; w->show(); return app.exec();} MainWindow::MainWindow();{ ui.setupUi( this ); connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(rasschet()));} void MainWindow::rasschet(){//Объявление переменныхint iS, oH, oM, oS, notH, notM;const int SiH=3600, SiM=60;QString inSec, outHr, outMin, outSec, Buffer;QSpinBox *spinBox = new QSpinBox;QTextEdit *textEdit = new QTextEdit;//ВводinSec = spinBox->text();iS = inSec.toInt();//Вычисление//Количество часовoH = (iS / SiH);//Убираем количество часовnotH = iS - (oH * SiH);//Количество минутoM = (notH / SiM);//Убираем количество минутnotM = notH - (oM * SiM);oS = notM;//Вывод результатаBuffer.sprintf("Введенное количество секунд %1f соответствует %1f часам, %1f минутам и %1f секундам \n", &iS, &oH, &oM, &oS);textEdit->setText(Buffer);}
C++ (Qt)#ifndef PROGA1_H#define PROGA1_H #include <QMainWindow>#include <QObject>#include "ui_proga1.h" class MainWindow : public QMainWindow{ Q_OBJECTpublic: MainWindow(); private slots: void rasschet(); private: Ui::MainWindow ui;}; #endif
#include <QApplication>#include "ui_proga1.h"#include "proga1.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); Ui::MainWindow mainWindow; QMainWindow *w = new QMainWindow; mainWindow.setupUi(w); w->show(); return app.exec();}
#include "proga1.h"#include "ui_proga1.h"MainWindow::MainWindow(){ui.setupUi(this);connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(rasschet()));}void MainWindow::rasschet(){//Объявление переменныхint iS, oH, oM, oS, notH, notM;const int SiH=3600, SiM=60;QString inSec, outHr, outMin, outSec, Buffer;QSpinBox *spinBox = new QSpinBox;QTextEdit *textEdit = new QTextEdit;//ВводinSec = spinBox->text();iS = inSec.toInt();//Вычисление//Количество часовoH = (iS / SiH);//Убираем количество часовnotH = iS - (oH * SiH);//Количество минутoM = (notH / SiM);//Убираем количество минутnotM = notH - (oM * SiM);oS = notM;//Вывод результатаBuffer.sprintf("Введенное количество секунд %1f соответствует %1f часам, %1f минутам и %1f секундам \n", &iS, &oH, &oM, &oS);textEdit->setText(Buffer);}
#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include <QObject>#include "ui_proga1.h"class MainWindow : public QMainWindow{ Q_OBJECTpublic: MainWindow();private slots: void rasschet();private: Ui::MainWindow ui;};#endif
#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())); }public slots: void rasschet();};#endif
#include <QtCore>#include "proga1.h"#include "ui_proga1.h"void MainWindow::rasschet(){//Объявление переменныхint iS, oS, notH, notM;float oH, oM;const int SiH=3600, SiM=60;QString inSec, outHr, outMin, outSec, Buffer;textEdit->clear();//ВводinSec = spinBox->text();qDebug() << inSec;iS = inSec.toInt();qDebug() << iS;//Вычисление//Количество часовoH = (iS / 3600);//Убираем количество часовnotH = iS - (oH * SiH);//Количество минутoM = (iS / 60);//Убираем количество минутnotM = notH - (oM * SiM);oS = iS;//Вывод результатаBuffer.sprintf("Entered seconds %d correspond %1.1f houres, %1.1f minutes and %d seconds \n", iS, oH, oM, oS);textEdit->setText(Buffer);}
#include <QApplication>#include "proga1.h"int main(int argc, char *argv[]){ QApplication app(argc, argv); MainWindow w; w.show(); return app.exec();}
MainWindow(QMainWindow* p = 0) : QMainWindow(p)
#include <QtCore>qDebug() << inSec;float oH, oM; //почему формат исходящих часов и минут не int
QTextCodec *coder;QTextCodec::codecForName("UTF8");Result = coder->toUnicode(Buffer);textEdit->setText(Result);
//Вычисление//Количество часовoH = (iS / 3600);//Убираем количество часовnotH = iS - (oH * SiH);//Количество минутoM = (notH / 60);//Убираем количество минутnotM = notH - (oM * SiM);oS = notM;
QByteArray encodedString = "Введенное количество секунд ";int seconds = 60;QByteArray result;result.setNum(seconds);encodedString += result;QTextCodec *codec = QTextCodec::codecForName("UTF-8");Buffer = codec->toUnicode(encodedString);textEdit->setText(Buffer);
QByteArray encodedString1 = "Введенное количество секунд ", encodedString2 = " соответствует ", encodedString3 = " часам, ", encodedString4 = " минутам, ", encodedString5 = " секундам.";QByteArray result1, result2, result3, result4;result1.setNum(iS);result2.setNum(oH);result3.setNum(oM);result4.setNum(oS);encodedString1 += result1 += encodedString2 += result2 += encodedString3 += result3 += encodedString4 += result4 +=encodedString5;QTextCodec *codec = QTextCodec::codecForName("Windows-1251");Buffer = codec->toUnicode(encodedString1);textEdit->setText(Buffer);