资源简介
用QT实现的简单计算器,包含加减乘除、开方、平方、求导、记忆等功能。
代码片段和文件信息
#include “calculatorstandard.h“
#include “ui_calculatorstandard.h“
CalculatorStandard::CalculatorStandard(QWidget *parent) :
QMainWindow(parent)
ui(new Ui::CalculatorStandard)
{
ui->setupUi(this);
waitingForOperand = true;
//0-9数字按键
connect(ui->pushButton_ZeroSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_OneSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_TwoSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_ThreeSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_FourSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_FiveSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_SixSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_SevenSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_EightSIGNAL(clicked())thisSLOT(digitClicked()));
connect(ui->pushButton_NineSIGNAL(clicked())thisSLOT(digitClicked()));
//加减按键
connect(ui->pushButton_AddSIGNAL(clicked())thisSLOT(addAndSubClicked()));
connect(ui->pushButton_SubSIGNAL(clicked())thisSLOT(addAndSubClicked()));
//乘除按键
connect(ui->pushButton_MulSIGNAL(clicked())thisSLOT(MulAndDerivativeClicked()));
connect(ui->pushButton_DivSIGNAL(clicked())thisSLOT(MulAndDerivativeClicked()));
//等于号按键
connect(ui->pushButton_EqualSIGNAL(clicked())thisSLOT(EqualClicked()));
//清除按键
connect(ui->pushButton_ClearSIGNAL(clicked())thisSLOT(clear()));
connect(ui->pushButton_ClearAllSIGNAL(clicked())thisSLOT(clearAll()));
//空格按键
connect(ui->pushButton_BackspaceSIGNAL(clicked())thisSLOT(backspaceClicked()));
//小数点按键
connect(ui->pushButton_PointSIGNAL(clicked())thisSLOT(pointClicked()));
//MC MR MS M+按键
connect(ui->pushButton_MCSIGNAL(clicked())thisSLOT(MCclicked()));
connect(ui->pushButton_MRSIGNAL(clicked())thisSLOT(MRclicked()));
connect(ui->pushButton_MSSIGNAL(clicked())thisSLOT(MPlusclicked()));
//正负切换按键
connect(ui->pushButton_PlusminusSIGNAL(clicked())thisSLOT(plusMinusClicked()));
//开方,平方,求导
connect(ui->pushButton_DerivativeSIGNAL(clicked())thisSLOT(otherOperatorclicked()));
connect(ui->pushButton_SqrtSIGNAL(clicked())thisSLOT(otherOperatorclicked()));
connect(ui->pushButton_X_2SIGNAL(clicked())thisSLOT(otherOperatorclicked()));
}
CalculatorStandard::~CalculatorStandard()
{
delete ui;
}
void CalculatorStandard::digitClicked ()
{
//当某一个object emit一个signal的时候,它就是一个sender系统会记录下当前是谁emit出这个signal的,
//所以你在对应的slot里就可以通过 sender()得到当前是谁invoke了你的slot,对应的是Qobject->d->sender.
//有可能多个 object的signal会连接到同一个signal(例如多个Button可能会connect到一个slot函数onclick())
//因此这是就 需要判断到底是哪个object emit了这个signal,根据sender的不同来进行不同的处理.
QPushButton *clickedButton = qobject_cast(sender());
//int digitValue = clickedButton->text().toInt();
//qDebug()<< ui-
相关资源
- 汇编计算器
- DCMTK库编译与在QT中的使用
- Linux综合实验GTK+单词计算器
- 实用Qt编写的图片浏览器
- Qt模拟时钟+数字时钟+万年历的程序
- Qt编写串口通信程序图文详解
- QTP破解文件mgn-mqt82.exe
- 智能家居系统QT源代码
- Qt5---编译的FTP库
- Qt开发软件数据获取助手源码
- 26 用AVR与1601LCD设计的计算器.zip
- qt案例二精美的多功能计算器
- Qt使用gSoap进行简单C/S程序开发
- Qt 图片查看器
- Qt 文本编辑器
- imx6系列处理器移植Qt5.6过程详细说明
- QTI传感器测试程序
- 酷炫服装语音计算器带捆条,缩水计
- ios手机端集成mqtt接受服务器推送消息
- 用Qt实现的写字板源码
- Qt 开源动态坐标带时间标非qwt实时曲
- 实用Qt指示灯
- 基于Qt的整数按位反转实现
- 不确定度计算器,可算A类和B类
- UDP通信QT
- 在Freescale iMX28 or iMX515上,移植QT过程
- linux下的QT串口通信
- Qt5.12.0 VS2017 64位 编译Qt5WebEngine实现
- 80c51单片机4位数码管计算器设计
- demo-QMdiSubWindow.rar
评论
共有 条评论