#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
河上七月
- 粉丝: 65
- 资源: 10
最新资源
- (源码)基于C语言的系统服务框架.zip
- (源码)基于Spring MVC和MyBatis的选课管理系统.zip
- (源码)基于ArcEngine的GIS数据处理系统.zip
- (源码)基于JavaFX和MySQL的医院挂号管理系统.zip
- (源码)基于IdentityServer4和Finbuckle.MultiTenant的多租户身份认证系统.zip
- (源码)基于Spring Boot和Vue3+ElementPlus的后台管理系统.zip
- (源码)基于C++和Qt框架的dearoot配置管理系统.zip
- (源码)基于 .NET 和 EasyHook 的虚拟文件系统.zip
- (源码)基于Python的金融文档智能分析系统.zip
- (源码)基于Java的医药管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论5