From b473499a29159038262f225682a24212f31911d3 Mon Sep 17 00:00:00 2001 From: iridiumR Date: Mon, 21 Mar 2022 22:54:10 +0800 Subject: [PATCH] =?UTF-8?q?2-1=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SoftwareDesign/Code/2-1/mainwindow.cpp | 9 ++++ SoftwareDesign/Code/2-1/mainwindow.h | 3 ++ SoftwareDesign/Code/2-1/mainwindow.ui | 58 +++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 5 deletions(-) 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 + + + + + + + + + + + + + + + + + + + = + + + + + + + + + + + + + 0 + 0 + 595 + 30 + + +