#include <QApplication>#include "ui_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();}Ui_MainWindow::Ui_MainWindow(){connect(pushButton, SIGNAL(clicked()), this, SLOT(rasschet()));}void Ui_MainWindow::rasschet(){далее процедура рассчета}
#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 QWidget{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; public slots: void rasschet(); 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
#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();}MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent){QPushButton *pushButton = new QPushButton;QSpinBox *spinBox = new QSpinBox;QObject::connect(pushButton, SIGNAL(clicked()), spinBox, SLOT(rasschet()));}void MainWindow::rasschet(){тут будет сама процедура рассчета написана}
#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 QWidget{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
#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include "ui_proga1.h"class MainWindow : public QMainWindow, public Ui::MainWindow{ Q_OBJECTpublic: MainWindow(QMainWindow *parent = 0);private slots: rasschet(int);};#endif
C++ (Qt)#include "proga1.h"MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent){ QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(rasschet()));}void MainWindow::rasschet(){тут будет сама процедура рассчета написана}
C++ (Qt)#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();}
C++ (Qt)MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent){ QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(rasschet()));}
C++ (Qt)class MainWindow : public QMainWindow, public Ui::MainWindow{...}; MainWindow::MainWindow(){ setupUi( this ); connect( pushButton, SIGNAL( clicked() ), this, SLOT( rasschet() ) );}
C++ (Qt)class MainWindow : public QMainWindow{...private: Ui::MainWindow ui;}; MainWindow::MainWindow(){ ui.setupUi( this ); connect( ui.pushButton, SIGNAL( clicked() ), this, SLOT( rasschet() ) );}
#ifndef PROGA1_H#define PROGA1_H#include <QMainWindow>#include "ui_proga1.h"class MainWindow : public QMainWindow, public Ui::MainWindow{ Q_OBJECTprivate slots: void rasschet();private: Ui::MainWindow ui;};MainWindow::MainWindow(){ ui.setupUi(this); connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(rasschet()));}#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();}void MainWindow::rasschet(){}
C++ (Qt)#ifndef PROGA1_H#define PROGA1_H #include <QMainWindow>#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
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();} void MainWindow::rasschet(){}