资源简介
这是用QT编写的只实现简单加减乘除运算的计算器,没有使用UI,界面纯手工。简单易懂,是初学者的良好引导者,程序完全可以运行成功。
代码片段和文件信息
#include “calc.h“
#include
#include
#include
Calc::Calc(QWidget *parent)
: QWidget(parent)
{
operator1=“0“;
operator2=“0“;
i=0;
setWindowtitle(“calculator“);
display=new QLineEdit(“0“);
display->setReadOnly(true);
display->setAlignment(Qt::AlignRight);
display->setMaxLength(300);
one=new QPushButton(“1“);
two=new QPushButton(“2“);
three=new QPushButton(“3“);
four=new QPushButton(“4“);
five=new QPushButton(“5“);
six=new QPushButton(“6“);
seven=new QPushButton(“7“);
eight=new QPushButton(“8“);
nine=new QPushButton(“9“);
zero=new QPushButton(“0“);
sub=new QPushButton(“-“);
mul=new QPushButton(“*“);
div=new QPushButton(“/“);
equal=new QPushButton(“=“);
add=new QPushButton(“+“);
point=new QPushButton(“.“);
clear=new QPushButton(“clear“);
backspace=new QPushButton(“backspace“);
connect(oneSIGNAL(clicked())thisSLOT(oneClicked()));
connect(twoSIGNAL(clicked())thisSLOT(twoClicked()));
connect(threeSIGNAL(clicked())thisSLOT(threeClicked()));
connect(fourSIGNAL(clicked())thisSLOT(fourClicked()));
connect(fiveSIGNAL(clicked())thisSLOT(fiveClicked()));
connect(sixSIGNAL(clicked())thisSLOT(sixClicked()));
connect(sevenSIGNAL(clicked())thisSLOT(sevenClicked()));
connect(eightSIGNAL(clicked())thisSLOT(eightClicked()));
connect(nineSIGNAL(clicked())thisSLOT(nineClicked()));
connect(zeroSIGNAL(clicked())thisSLOT(zeroClicked()));
connect(subSIGNAL(clicked())thisSLOT(subClicked()));
connect(mulSIGNAL(clicked())thisSLOT(mulClicked()));
connect(divSIGNAL(clicked())thisSLOT(divClicked()));
connect(pointSIGNAL(clicked())thisSLOT(pointClicked()));
connect(equalSIGNAL(clicked())thisSLOT(equalClicked()));
connect(addSIGNAL(clicked())thisSLOT(addClicked()));
connect(clearSIGNAL(clicked())thisSLOT(clearClicked()));
connect(backspaceSIGNAL(clicked())thisSLOT(backspaceClicked()));
QVBoxLayout *mainlayout=new QVBoxLayout();
QVBoxLayout *toplayout=new QVBoxLayout;
toplayout->addWidget(display);
QHBoxLayout *button1=new QHBoxLayout;
button1->addWidget(one);
button1->addWidget(two);
button1->addWidget(three);
button1->addWidget(four);
QHBoxLayout *button2=new QHBoxLayout;
button2->addWidget(five);
button2->addWidget(six);
button2->addWidget(seven);
button2->addWidget(eight);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9699 2013-10-09 13:29 calc\calc.cpp
文件 1206 2013-10-08 16:53 calc\calc.h
文件 319 2013-10-05 15:19 calc\calce.pro
文件 17744 2013-10-13 12:43 calc\calce.pro.user
文件 164 2013-10-05 15:48 calc\main.cpp
..AD... 0 2013-10-13 12:43 calc
----------- --------- ---------- ----- ----
29132 6
相关资源
- 基于OpenCV3.2+Qt5.8的basler相机硬件触发
- Qt mqtt通信
-
QMediaPla
yer多窗口播放视频 - Qt使用vlc库播放视频
- 计算器图形化界面Qt版
- QT自定义精美换肤界面转
- QT5 简易多媒体播放器
- QT使用样式表进行界面美化
- QT的QSS教程
- 大恒相机QT例程LINUX
- SecureCRTTomcat工程发布到linux系统上
- QT的简要界面设计的一个
- 基于 qt的gstreamer 应用,
- 基于QT的网络聊天室+收发数据及文件
- QT 不规则悬浮球 仿360
- qt数据画波形
- qt 实现ftp服务器源码
- VTK应用之VTK与Qt整合的
- qt实现的滑动设置时间自定义控件
- Qt的pro文件转VS的工程文件
- QT Qudpsocket 传送结构体数据
- Qt 使用多线程QThread实现进度条
- JasonQt_BaiduVop Demo
- Qt实现半透明不规则窗体的
- qtwinmigrate-2.8_1-opensource_qt5.7
- image_process.zip
- Qt 自绘波形图 心电图 的 实时显示
- Qt实现高级组织结构图
- Qt实现绘图工具
- Qt实现网络拓扑图
评论
共有 条评论