diff --git a/SoftwareDesign/Code/2-1/mainwindow.cpp b/SoftwareDesign/Code/2-1/mainwindow.cpp
index 41a26bd..920463b 100644
--- a/SoftwareDesign/Code/2-1/mainwindow.cpp
+++ b/SoftwareDesign/Code/2-1/mainwindow.cpp
@@ -13,3 +13,12 @@ MainWindow::~MainWindow()
delete ui;
}
+
+void MainWindow::on_cal_clicked()
+{
+ int a = ui->num1->value();
+ int b = ui->num2->value();
+ ui->answer->setText(QString::number(a+b));
+
+}
+
diff --git a/SoftwareDesign/Code/2-1/mainwindow.h b/SoftwareDesign/Code/2-1/mainwindow.h
index 4643e32..07b6ec6 100644
--- a/SoftwareDesign/Code/2-1/mainwindow.h
+++ b/SoftwareDesign/Code/2-1/mainwindow.h
@@ -15,6 +15,9 @@ public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
+private slots:
+ void on_cal_clicked();
+
private:
Ui::MainWindow *ui;
};
diff --git a/SoftwareDesign/Code/2-1/mainwindow.ui b/SoftwareDesign/Code/2-1/mainwindow.ui
index b232854..033b8f0 100644
--- a/SoftwareDesign/Code/2-1/mainwindow.ui
+++ b/SoftwareDesign/Code/2-1/mainwindow.ui
@@ -6,15 +6,63 @@
0
0
- 800
- 600
+ 595
+ 214
- MainWindow
+ 简易计算器
-
-
+
+
+
+
+ 80
+ 16
+ 411
+ 121
+
+
+
+
+ 20
+
+ -
+
+
+ -
+
+
+ +
+
+
+
+ -
+
+
+ -
+
+
+ =
+
+
+
+ -
+
+
+
+
+
+