• 大小: 3.11MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-21
  • 语言: 其他
  • 标签: qt  计算器  

资源简介

基于QT做的计算器,加减乘除、阶乘、x的n次方,开根号、部分三角运算

资源截图

代码片段和文件信息

#include “calculate.h“
#include “ui_calculate.h“
#include 
#include   
#include   
#include 
#include 

Calculate::Calculate(QWidget *parent) :
    QWidget(parent)
    ui(new Ui::Calculate)
{
    ui->setupUi(this);
    timer = new QTimer(this);
    timer->start(1000);
    first = 0;
    second = 0;
    result = 0;
    b = 1;
    flag1 = 0;
}

Calculate::~Calculate()
{
    delete ui;
}
void Calculate::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
        switch (e->type()) {
        case QEvent::LanguageChange:
            ui->retranslateUi(this);
            break;
        default:
            break;
        }

}

void Calculate::on_pushButton_clicked()
{
    str += ui->pushButton->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_2_clicked()
{
    str += ui->pushButton_2->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_3_clicked()
{
    str += ui->pushButton_3->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_4_clicked()
{
    str += ui->pushButton_4->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_5_clicked()
{
    str += ui->pushButton_5->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_6_clicked()
{
    str += ui->pushButton_6->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_7_clicked()
{
    str += ui->pushButton_7->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_8_clicked()
{
    str += ui->pushButton_8->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_9_clicked()
{
    str += ui->pushButton_9->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_10_clicked()
{
    str += ui->pushButton_10->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_11_clicked()
{
    str += ui->pushButton_11->text();
    opt1 = str.toDouble();
    ui->lineEdit->setText(QString::number(opt1));
}

void Calculate::on_pushButton_12_clicked()
{
    flag = ‘+‘;
    if(flag1 == 0)
    {
       first = opt1;
       opt1 = 0;
    }
    str = ““;
}

void Calculate::on_pushButton_13_clicked()
{
    flag = ‘-‘;
    if(flag1 == 0)
    {
        first = opt1;
        opt1 = 0;
    }
    str =““;
}

void Calculate::on_pushButton_14_clicked()
{
    flag = ‘*‘;
    if(flag1 == 0)
    {
        first = opt1;
         

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6779  2011-06-22 11:46  calculate\calculate.cpp

     文件       1915  2010-11-30 21:08  calculate\calculate.h

     文件        328  2010-10-28 12:17  calculate\calculate.pro

     文件      11130  2011-07-21 12:01  calculate\calculate.pro.user

     文件      10278  2011-06-23 09:03  calculate\calculate.ui

     文件    3442275  2011-06-23 09:04  calculate\debug\calculate.exe

     文件    2111981  2011-06-23 09:04  calculate\debug\calculate.o

     文件     590776  2011-06-22 11:42  calculate\debug\main.o

     文件       5961  2011-06-22 11:42  calculate\debug\moc_calculate.cpp

     文件     600926  2011-06-22 11:42  calculate\debug\moc_calculate.o

     文件        187  2010-10-28 14:55  calculate\main.cpp

     文件       5659  2011-07-21 11:53  calculate\Makefile

     文件       5494  2011-07-21 11:53  calculate\Makefile.Debug

     文件       5567  2011-07-21 11:53  calculate\Makefile.Release

     文件     960189  2011-06-22 11:41  calculate\qtc-gdbmacros\debug\gdbmacros.dll

     文件     884012  2011-06-22 11:41  calculate\qtc-gdbmacros\debug\gdbmacros.o

     文件       1472  2011-06-22 11:41  calculate\qtc-gdbmacros\debug\libgdbmacros.a

     文件      81686  2009-02-25 17:58  calculate\qtc-gdbmacros\gdbmacros.cpp

     文件         57  2009-02-20 22:54  calculate\qtc-gdbmacros\gdbmacros.pro

     文件        536  2009-02-27 16:30  calculate\qtc-gdbmacros\LGPL_EXCEPTION.TXT

     文件      26938  2009-02-27 16:30  calculate\qtc-gdbmacros\LICENSE.LGPL

     文件       5707  2011-07-21 12:00  calculate\qtc-gdbmacros\Makefile

     文件       4738  2011-07-21 12:00  calculate\qtc-gdbmacros\Makefile.Debug

     文件       4787  2011-07-21 12:00  calculate\qtc-gdbmacros\Makefile.Release

     文件      11934  2011-06-23 09:03  calculate\ui_calculate.h

     目录          0  2011-06-22 11:41  calculate\qtc-gdbmacros\debug

     目录          0  2011-06-22 11:41  calculate\qtc-gdbmacros\release

     目录          0  2011-06-23 09:04  calculate\debug

     目录          0  2011-06-22 11:41  calculate\qtc-gdbmacros

     目录          0  2011-06-22 11:41  calculate\release

............此处省略4个文件信息

评论

共有 条评论