没有加入弹出窗口
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pushButton_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(on_pushButton_clicked()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
int first = ui->first->text().toInt();
int second = ui->second->text().toInt();
int result;
switch (ui->comboBox->currentIndex()) {
case 0:
result = first + second;
break;
case 1:
result = first - second;
break;
case 2:
result = first * second;
break;
case 3:
if(second < 0)
return;
result = first / second;
break;
default:
break;
}
// int first = ui->first->text().toInt();
// int second = ui->second->text().toInt();
// int sum = first + second;
ui->sum->setText(QString::number(result));
}