計算機的數字按鍵部分只設定了1,2,3,4四個按鍵,剩下的幾個可以自行新增
main.cpp中的檔案就是預設檔案,沒有改動1.mainwindow.h //下面private slots中的函式需要手動在ui介面中設定槽
#ifndef mainwindow_h
#define mainwindow_h
#include
namespace ui
class
mainwindow
:public qmainwindow
;#endif
// mainwindow_h
mainwindow.cpp
#include
"mainwindow.h"
#include
"ui_mainwindow.h"
mainwindow::
mainwindow
(qwidget *parent)
:qmainwindow
(parent),ui
(new ui::mainwindow)
mainwindow::
~mainwindow()
void mainwindow::
on_pushbutton_add_clicked()
void mainwindow::
on_pushbutton_sub_clicked()
void mainwindow::
on_pushbutton_mul_clicked()
void mainwindow::
on_pushbutton_div_clicked()
void mainwindow::
on_pushbutton_1_clicked()
else
}void mainwindow::
on_pushbutton_2_clicked()
else
}void mainwindow::
on_pushbutton_3_clicked()
else
}void mainwindow::
on_pushbutton_4_clicked()
else
}void mainwindow::
on_pushbutton_equal_clicked()
if(flag ==2)
if(flag ==3)
if(flag ==4)
qstring str;
str = str.
number
(result)
; ui-
>lineedit-
>
settext
(str)
; flag =0;
op1 ="";
op2 ="";
}void mainwindow::
on_pushbutton_clear_clicked()
void mainwindow::
on_pushbutton_point_clicked()
else
}void mainwindow::
on_pushbutton_delete_clicked()
else
}
實現計算機
實現乙個計算器 實現兩個運算元 小數和整數均可 的加 減 乘 除 清零操作。1.加法運算 2.減法運算 3.乘法運算 4.除法運算 64 16 4 using system using system.collections.generic using system.componentmodel us...
最簡單的計算機
乙個名叫是 pigheadthree 的研究組織設計了一台實驗用的計算機,命名為 ppmm。ppmm只能執行簡單的六種命令 a,b,c,d,e,f 只有二個記憶體 m1,m2 三個暫存器 r1,r2,r3。六種命令的含義如下 命令 a 將記憶體 m1 的資料裝到暫存器 r1 中 命令 b 將記憶體 ...
最簡單計算機
乙個名叫是pigheadthree的研究組織設計了一台實驗用的計算機,命名為ppmm。ppmm只能執行簡單的六種命令a,b,c,d,e,f 只有二個記憶體m1,m2 三個暫存器r1,r2,r3。六種命令的含義如下 命令a 將記憶體m1的資料裝到暫存器r1中 命令b 將記憶體m2的資料裝到暫存器r2中...