代码如下:
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->calcButton,SIGNAL(clicked()),this,SLOT(calcSlot()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::calcSlot()
{
int first = ui->fistlineEdit->text().toInt();
int second = ui->secondlineEdit->text().toInt();
int result;
if(ui->comboBox->currentIndex() == 0){
result = first + second;
}
else if(ui->comboBox->currentIndex() == 1){
result = first - second;
}
else if(ui->comboBox->currentIndex() &