#include "calculator.h"
calculator::calculator(QWidget *parent)
: QDialog(parent)
{
finish_sign=0;
m_opr.push(make_unique<Hash>());
initUI();
initSLOTS();
}
void calculator::initUI()
{
this -> setWindowTitle("计算器20171004306");
//数字pi.
num_0 = new QPushButton(tr("0"));
num_1 = new QPushButton(tr("1"));
num_2 = new QPushButton(tr("2"));
num_3 = new QPushButton(tr("3"));
num_4 = new QPushButton(tr("4"));
num_5 = new QPushButton(tr("5"));
num_6 = new QPushButton(tr("6"));
num_7 = new QPushButton(tr("7"));
num_8 = new QPushButton(tr("8"));
num_9 = new QPushButton(tr("9"));
pi = new QPushButton(tr("pi"));
dot = new QPushButton(tr("."));
//操作符
clearh = new QPushButton(tr("CHistory"));
lbracket = new QPushButton(tr("("));
rbracket = new QPushButton(tr(")"));
msin = new QPushButton(tr("sin"));
mcos = new QPushButton(tr("cos"));
mtan = new QPushButton(tr("tan"));
mod = new QPushButton(tr("%"));
power = new QPushButton(tr("^"));
mul = new QPushButton(tr("*"));
div = new QPushButton(tr("/"));
add = new QPushButton(tr("+"));
sub = new QPushButton(tr("-"));
zero = new QPushButton(tr("ce"));
back = new QPushButton(tr("c"));
psqrt = new QPushButton(tr("√"));
equ = new QPushButton(tr("="));
equ2 = new QPushButton(tr("="));
change = new QPushButton(tr("+/-"));
mln = new QPushButton(tr("ln"));
mlog = new QPushButton(tr("log"));
em = new QPushButton(tr("exp()"));
masin = new QPushButton(tr("asin"));
macos = new QPushButton(tr("acos"));
matan = new QPushButton(tr("atan"));
fact = new QPushButton(tr("n!"));
rec = new QPushButton(tr("1/x"));
//大小设置
QSizePolicy police= num_0->sizePolicy();
police.setVerticalPolicy(QSizePolicy::Minimum);
num_1->setSizePolicy(police);
num_2->setSizePolicy(police);
num_3->setSizePolicy(police);
num_4->setSizePolicy(police);
num_5->setSizePolicy(police);
num_6->setSizePolicy(police);
num_7->setSizePolicy(police);
num_8->setSizePolicy(police);
num_9->setSizePolicy(police);
num_0->setSizePolicy(police);
lbracket->setSizePolicy(police);
rbracket->setSizePolicy(police);
pi->setSizePolicy(police);
msin->setSizePolicy(police);
mcos->setSizePolicy(police);
mtan->setSizePolicy(police);
mod->setSizePolicy(police);
power->setSizePolicy(police);
add->setSizePolicy(police);
sub->setSizePolicy(police);
mul->setSizePolicy(police);
div->setSizePolicy(police);
zero->setSizePolicy(police);
back->setSizePolicy(police);
dot->setSizePolicy(police);
psqrt->setSizePolicy(police);
equ->setSizePolicy(police);
equ2->setSizePolicy(police);
change->setSizePolicy(police);
mln->setSizePolicy(police);
mlog->setSizePolicy(police);
em->setSizePolicy(police);
masin->setSizePolicy(police);
macos->setSizePolicy(police);
matan->setSizePolicy(police);
rec->setSizePolicy(police);
fact->setSizePolicy(police);
clearh->setSizePolicy(police);
//test
num_02 = new QPushButton(tr("0"));
num_12 = new QPushButton(tr("1"));
num_22 = new QPushButton(tr("2"));
num_32 = new QPushButton(tr("3"));
num_42 = new QPushButton(tr("4"));
num_52 = new QPushButton(tr("5"));
num_62 = new QPushButton(tr("6"));
num_72 = new QPushButton(tr("7"));
num_82 = new QPushButton(tr("8"));
num_92 = new QPushButton(tr("9"));
dot2 = new QPushButton(tr("."));
lbracket2 = new QPushButton(tr("("));
rbracket2 = new QPushButton(tr(")"));
mul2 = new QPushButton(tr("*"));
div2 = new QPushButton(tr("/"));
add2 = new QPushButton(tr("+"));
sub2 = new QPushButton(tr("-"));
zero2 = new QPushButton(tr("ce"));
back2 = new QPushButton(tr("c"));
equ2 = new QPushButton(tr("="));
num_12->setSizePolicy(police);
num_22->setSizePolicy(police);
num_32->setSizePolicy(police);
num_42->setSizePolicy(police);
num_52->setSizePolicy(police);
num_62->setSizePolicy(police);
num_72->setSizePolicy(police);
num_82->setSizePolicy(police);
num_92->setSizePolicy(police);
num_02->setSizePolicy(police);
lbracket2->setSizePolicy(police);
rbracket2->setSizePolicy(police);
add2->setSizePolicy(police);
sub2->setSizePolicy(police);
mul2->setSizePolicy(police);
div2->setSizePolicy(police);
zero2->setSizePolicy(police);
back2->setSizePolicy(police);
dot2->setSizePolicy(police);
QGridLayout *test_cal = new QGridLayout;
test_cal->addWidget(num_02, 4, 1, 1, 1);
test_cal->addWidget(num_12, 3, 1, 1, 1);
test_cal->addWidget(num_22, 3, 2, 1, 1);
test_cal->addWidget(num_32, 3, 3, 1, 1);
test_cal->addWidget(num_42, 2, 1, 1, 1);
test_cal->addWidget(num_52, 2, 2, 1, 1);
test_cal->addWidget(num_62, 2, 3, 1, 1);
test_cal->addWidget(num_72, 1, 1, 1, 1);
test_cal->addWidget(num_82, 1, 2, 1, 1);
test_cal->addWidget(num_92, 1, 3, 1, 1);
test_cal->addWidget(dot2, 4, 2, 1, 1);
test_cal->addWidget(equ2, 4, 3, 1, 1);
test_cal->addWidget(back2, 0, 3, 1, 1);
test_cal->addWidget(zero2, 0, 2, 1, 1);
test_cal->addWidget(rbracket2, 0, 1, 1, 1);
test_cal->addWidget(lbracket2, 0, 0, 1, 1);
test_cal->addWidget(add2, 1, 0, 1, 1);
test_cal->addWidget(sub2, 2, 0, 1, 1);
test_cal->addWidget(mul2, 3, 0, 1, 1);
test_cal->addWidget(div2, 4, 0, 1, 1);
//数字基础颜色更改
num_0->setStyleSheet("background: rgb(169,169,169)");
num_1->setStyleSheet("background: rgb(169,169,169)");
num_2->setStyleSheet("background: rgb(169,169,169)");
num_3->setStyleSheet("background: rgb(169,169,169)");
num_4->setStyleSheet("background: rgb(169,169,169)");
num_5->setStyleSheet("background: rgb(169,169,169)");
num_6->setStyleSheet("background: rgb(169,169,169)");
num_7->setStyleSheet("background: rgb(169,169,169)");
num_8->setStyleSheet("background: rgb(169,169,169)");
num_9->setStyleSheet("background: rgb(169,169,169)");
dot->setStyleSheet("background: rgb(169,169,169)");
//中部栅格
QGridLayout *num = new QGridLayout;
num->addWidget(num_0, 4, 2, 1, 2);
num->addWidget(num_1, 3, 2, 1, 1);
num->addWidget(num_2, 3, 3, 1, 1);
num->addWidget(num_3, 3, 4, 1, 1);
num->addWidget(num_4, 2, 2, 1, 1);
num->addWidget(num_5, 2, 3, 1, 1);
num->addWidget(num_6, 2, 4, 1, 1);
num->addWidget(num_7, 1, 2, 1, 1);
num->addWidget(num_8, 1, 3, 1, 1);
num->addWidget(num_9, 1, 4, 1, 1);
num->addWidget(zero, 0, 4, 1, 1);
num->addWidget(dot, 4, 4, 1, 1);
num->addWidget(rbracket,0,3,1,1);
num->addWidget(lbracket,0,2,1,1);
num->addWidget(add, 0, 1, 1, 1);
num->addWidget(sub, 1, 1, 1, 1);
num->addWidget(mul, 2, 1, 1, 1);
num->addWidget(div, 3, 1, 1, 1);
num->addWidget(change, 4, 1, 1, 1);
num->addWidget(power, 0, 0, 1, 1);
num->addWidget(mod, 1, 0, 1, 1);
num->addWidget(fact, 2, 0, 1, 1);
num->addWidget(rec, 3, 0, 1, 1);
num->addWidget(em, 4, 0, 1, 1);
//顶部水平布局
QHBoxLayout *trangle = new QHBoxLayout;
trangle->addWidget(msin);
trangle->addWidget(mcos);
trangle->addWidget(mtan);
trangle->addWidget(masin);
trangle->addWidget(macos);
trangle->addWidget(matan);
trangle->addWidget(clearh);
//左部垂直布局
QVBoxLayout *tleft = new QVBoxLayout;
tleft->addWidget(psqrt);
tleft->addWidget(pi);
tleft->addWidget(mln);
tleft->addWidget(mlog);
//右部垂直布局
QVBoxLayout *tright = new QVBoxLayout;
tright->addWidget(back);
tright->addWidget(equ);
//常用界面
QHB
河上七月
- 粉丝: 67
- 资源: 10
最新资源
- qaxbrowser-1.1.32574.52.exe (奇安信浏览器windows安装包)
- C#编写modbus tcp客户端读取modbus tcp服务器数据
- 某房地产瑞六补环境部分代码
- 基于Matlab实现无刷直流电机仿真(模型+说明文档).rar
- AllSort(直接插入排序,希尔排序,选择排序,堆排序,冒泡排序,快速排序,归并排序)
- 模拟qsort,改造冒泡排序使其能排序任意数据类型,即日常练习
- carsim+simulink联合仿真实现变道 包含路径规划算法+mpc轨迹跟踪算法 可选simulink版本和c++版本算法 可以适用于弯道道路,弯道车道保持,弯道变道 carsim内规划轨迹可视化
- 数组经典习题之顺序排序和二分查找和冒泡排序
- 永磁同步电机神经网络自抗扰控制,附带编程涉及到的公式文档,方便理解,模型顺利运行,效果好,位置电流双闭环采用二阶自抗扰控制,永磁同步电机三闭环控制,神经网络控制,自抗扰中状态扩张观测器与神经网络结合
- 基于 Oops Framework 提供的游戏项目开发模板,项目中提供了最新版本 Cocos Creator 3.x 插件与游戏资源初始化通用逻辑
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论5