资源简介
用QT designer编辑的一个计算器,希望对大家有用,功能简单,适合同学们上交作业使用
代码片段和文件信息
/*
* =====================================================================================
*
* Filename: calculator.cpp
*
* Description:
*
* Version: 1.0
* Created: 08/25/2010 09:20:15 PM
* Revision: none
* Compiler: gcc
*
* Author: TimBerWolF (ALL) 455436750@qq.com
* Company: http://hi.baidu.com/witwolf/space
*
* =====================================================================================
*/
#include“calculator.h“
#include
calculator::calculator(QWidget *parent)
:QDialog(parent){
setupUi(this);
level3=QRegExp(“[(]{11}.*[)]{11}“);
level2=QRegExp(“(\\d+\\.?\\d+)[*/]{11}(\\d+\\.?\\d+)“);
level1=QRegExp(“(\\d+\\.?\\d+)[+-]{11}(\\d+\\.?\\d+)“);
b=true;
//将单目运算变成双目运算(取负)表达式中所有“(-“换成“(0-“
rep=QRegExp(“[(]{11}[-]{11}“);
connect(quitSIGNAL(clicked())thisSLOT(close()));
connect(ACSIGNAL(clicked())resSLOT(clear()));
connect(ACSIGNAL(clicked())labelSLOT(clear()));
connect(oneSIGNAL(clicked())thisSLOT(oneClick()));
connect(twoSIGNAL(clicked())thisSLOT(twoClick()));
connect(threeSIGNAL(clicked())thisSLOT(threeClick()));
connect(fourSIGNAL(clicked())thisSLOT(fourClick()));
connect(fiveSIGNAL(clicked())thisSLOT(fiveClick()));
connect(sixSIGNAL(clicked())thisSLOT(sixClick()));
connect(sevenSIGNAL(clicked())thisSLOT(sevenClick()));
connect(eightSIGNAL(clicked())thisSLOT(eightClick()));
connect(nineSIGNAL(clicked())thisSLOT(nineClick()));
connect(zeroSIGNAL(clicked())thisSLOT(zeroClick()));
connect(addSIGNAL(clicked())thisSLOT(addClick()));
connect(minusSIGNAL(clicked())thisSLOT(minusClick()));
connect(multiplySIGNAL(clicked())thisSLOT(multiplyClick()));
connect(divideSIGNAL(clicked())thisSLOT(divideClick()));
connect(lBracketSIGNAL(clicked())thisSLOT(lBracketClick()));
connect(rBracketSIGNAL(clicked())thisSLOT(rBracketClick()));
connect(dotSIGNAL(clicked())thisSLOT(dotClick()));
connect(backSpaceSIGNAL(clicked())thisSLOT(backSpaceClick()));
connect(calculateSIGNAL(clicked())thisSLOT(calculateClick()));
}
void calculator::oneClick(){
res->setText(res->text()+tr(“1“));
}
void calculator::twoClick(){
res->setText(res->text()+tr(“2“));
}
void calculator::threeClick(){
res->setText(res->text()+tr(“3“));
}
void calculator::fourClick(){
res->setText(res->text()+tr(“4“));
}
void calculator::fiveClick(){
res->setText(res->text()+tr(“5“));
}
void calculator::sixClick(){
res->setText(res->text()+tr(“6“));
}
void calculator::sevenClick(){
res->setText(res->text()+tr(“7“));
}
void calculator::eightClick(){
res->setText(res->text()+tr(“8“));
}
void calculator::nineClick(){
res->setText(res->text()+tr(“9“));
}
void calculator::zeroClick(){
res->setText(res->text()+tr(“0“));
}
void calculator::lBracketClick(){
res->setText(res->text()+tr(“(“));
}
void calculator::rBracketClick(){
res->setText(res->text()+tr(“)“));
}
void calculator::addClick(){
- 上一篇:xp sp3 pci.sys
- 下一篇:金沙滩51单片机proteus文件
相关资源
- QT+release
- N皇后_Qt图形界面_
- QT日历程序
- qt 故障树 带画图功能
- QT绘制简单OpenGL图形
- Qt静态编译的设置过程Qt5.1.0
- QT4 QCA 加密库
- v4l2 qt实时显示摄像头数据未使用ope
- zigbee的串口编程应用源代码
- QT+opencv边缘检测,轮廓提取及轮廓跟
- QT+opencv图像增强,包括高斯平滑,中
- qt 串口通讯发送和接收都有
- DLL版计算器 编程练习必备
- QT5 下 usb 设备插拔检测
- 晶振电路仿真(ALTIUM DESIGNER)
- QWebChannel
- Qt双滑块滑动器(slider)控件
- QT 源码 圆形时钟
- 矩形空心线圈 计算器 LC谐振 计算器
- 基于QT+Linux的网络聊天室
- QGraphicsView Draw
- QT-玛丽奥医生的源代码
- 混合复数计算器
- SPWM计算器
- 简单四则运算计算器附带乘方运算
- QT画坐标系折线图
- Altium Designer16.06支持导入LOGO图标的脚
- MainWindow和Dialog通过信号和槽通信
- 在QGraphicsScene上画矩形
- Qt下使用GLSL的-变色的小球
评论
共有 条评论