btn_negative 按下 对数字取负数进行运算 应该怎么填写 槽信号
btn_negative 按下 对数字取负数进行运算 应该怎么填写 槽信号
btn_negative 按下 对数字取负数进行运算 应该怎么填写 槽信号
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 「已注销」 2021-08-11 16:35关注
#include "dialog.h"
#include "ui_dialog.h"Dialog::Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog)
{
ui->setupUi(this);
this->model = new class model;
this->tmp = "";}
Dialog::~Dialog()
{
delete ui;
}void Dialog::on_btn_0_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}if(this->str1!="") { QString str = "0"; str1.append(str); ui->label_oper->setText(str1); } if(this->tmp != "") { this->tmp += this->ui->btn_0->text(); this->ui->lcd_display->display(this->tmp); }
}
void Dialog::on_btn_1_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
_isNew = false;
str1 = "";
}
QString str = "1";
str1.append(str);
ui->label_oper->setText(str1);this->tmp += this->ui->btn_1->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_2_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "2"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_2->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_3_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "3"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_3->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_4_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "4"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_4->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_5_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "5"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_5->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_6_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "6"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_6->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_7_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "7"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_7->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_8_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "8"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_8->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_9_clicked()
{
if(_isNew)
{
ui->label_oper->clear();
// _isNew = false;
str1 = "";
}QString str = "9"; str1.append(str); ui->label_oper->setText(str1); this->tmp += this->ui->btn_9->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_C_clicked()
{
str1.clear();
this->ui->label_oper->clear();this->tmp.clear(); this->ui->lcd_display->display(0);
}
void Dialog::on_btn_CE_clicked()
{str1.clear(); this->ui->label_oper->clear(); this->tmp.clear(); this->ui->lcd_display->display(0);
}
void Dialog::on_btn_del_clicked()
{
this->ui->label_oper->clear();
tmp=tmp.left(tmp.length()-1);
this->ui->lcd_display->display(tmp);
}void Dialog::on_btn_equal_clicked()
{
QString resul = this->model->doExpr_2();
//this->ui->label_oper->setText(resul);QStringList Str_List = str1.split(""); Str_List[0] = Str_List[0].simplified(); arry[0] = Str_List[0].toDouble(); Str_List[2] = Str_List[2].simplified(); arry[2] = Str_List[2].toDouble();
// arry[0] = -arry[0];
float num = this->tmp.toFloat(); this->model->setNum2(num); QString res = this->model->doExpr_1(); this->ui->lcd_display->display(res); this->tmp = ""; _isNew = true;
}
void Dialog::on_btn_plus_clicked()
{
operat = '+';
QString str = " + ";
str1.append(str);
ui->label_oper->setText(str1);
oper='+';ui->label_oper->setText(oper); float num = this->tmp.toFloat(); this->model->setNum1(num); this->tmp = ""; QString ex = this->ui->btn_plus->text(); this->ui->lcd_display->display(this->tmp); this->model->setFlag(ex);
}
void Dialog::on_btn_sub_clicked()
{
operat = '-';
QString str = " - ";
str1.append(str);
ui->label_oper->setText(str1);oper='-'; ui->label_oper->setText(oper); float num = this->tmp.toFloat(); this->model->setNum1(num); this->tmp = ""; QString ex = this->ui->btn_sub->text(); this->model->setFlag(ex);
}
void Dialog::on_btn_mul_clicked()
{
operat = '*';
QString str = " * ";
str1.append(str);
ui->label_oper->setText(str1);oper='*'; ui->label_oper->setText(oper); float num = this->tmp.toFloat(); this->model->setNum1(num); this->tmp = ""; QString ex = this->ui->btn_mul->text(); this->model->setFlag(ex);
}
void Dialog::on_btn_div_clicked()
{
operat = '/';
QString str = " / ";
str1.append(str);
ui->label_oper->setText(str1);oper='/'; ui->label_oper->setText(oper); float num = this->tmp.toFloat(); this->model->setNum1(num); this->tmp = ""; QString ex = this->ui->btn_div->text(); this->model->setFlag(ex);
}
void Dialog::on_btn_point_clicked()
{
QString str = ".";
str1.append(str);
ui->label_oper->setText(str1);this->tmp += this->ui->btn_point->text(); this->ui->lcd_display->display(this->tmp);
}
void Dialog::on_btn_negative_clicked()
{
arry[0]=-arry[0];
arry[2]=-arry[2];}
解决 无用评论 打赏 举报
悬赏问题
- ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
- ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
- ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
- ¥20 神经网络Sequential name=sequential, built=False
- ¥16 Qphython 用xlrd读取excel报错
- ¥15 单片机学习顺序问题!!
- ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
- ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
- ¥15 相敏解调 matlab
- ¥15 求lingo代码和思路