#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QtGui/QWidget>
#include <QVBoxLayout>
#include <QLineEdit>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private slots:
void Rasschitat();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
#include "widget.h"
#include "math.h"
#include "ui_widget.h"
#include <QLineEdit>
#include <QPushButton>
Widget::Widget(QWidget *parent) : QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QVBoxLayout *mainLay = new QVBoxLayout(this);
ui->lineEdit->setInputMask("9999");
ui->lineEdit_2->setInputMask("9999");
ui->lineEdit_3->setInputMask("9999");
ui->lineEdit_4->setReadOnly(true);
ui->lineEdit_5->setReadOnly(true);
ui->lineEdit_6->setReadOnly(true);
ui->pushButton->connect( ui->pushButton, SIGNAL( clicked() ), SLOT // а какой должен быть,уже все перевводил!
QPushButton *clickMeBtn = new QPushButton("Rasschitat");
QObject::connect(clickMeBtn, SIGNAL(clicked()), this, SLOT(Rasschitat()));
mainLay->addWidget(clickMeBtn);
}
Widget::~Widget(){
delete ui;
}
void Widget::Rasschitat(){
ui->lineEdit_4->setText(QString::number(ui->lineEdit->text().toInt() * ui->lineEdit_2->text().toInt() * ui->lineEdit_3->text().toInt()));
ui->lineEdit_5->setText(QString::number(ui->lineEdit->text().toInt() * ui->lineEdit_2->text().toInt() * ui->lineEdit_3->text().toInt()));
ui->lineEdit_6->setText(QString::number(ui->lineEdit_4->text().toInt() + ui->lineEdit_5->text().toInt()));
}
вот что получилось:
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QtGui/QWidget>
#include <QVBoxLayout>
#include <QLineEdit>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private slots:
void Rasschitat();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
#include "widget.h"
#include "math.h"
#include "ui_widget.h"
#include <QLineEdit>
Widget::Widget(QWidget *parent) : QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->lineEdit->setInputMask("9999");
ui->lineEdit_2->setInputMask("9999");
ui->lineEdit_3->setInputMask("9999");
ui->lineEdit_4->setReadOnly(true);
ui->lineEdit_5->setReadOnly(true);
ui->lineEdit_6->setReadOnly(true);
ui->pushButton->connect(ui->pushButton, SIGNAL( clicked() ), SLOT(Rasschitat()));
QPushButton::; // незнаю что тут будет, ругается на все что вводил
}
Widget::~Widget(){
delete ui;
}
void Widget::Rasschitat(){
ui->lineEdit_4->setText(QString::number(ui->lineEdit->text().toInt() * ui->lineEdit_2->text().toInt() * ui->lineEdit_3->text().toInt()));
ui->lineEdit_5->setText(QString::number(ui->lineEdit->text().toInt() * ui->lineEdit_2->text().toInt() * ui->lineEdit_3->text().toInt()));
ui->lineEdit_6->setText(QString::number(ui->lineEdit_4->text().toInt() + ui->lineEdit_5->text().toInt()));
}
помогите пожалуйста