• 大小: 41KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: 其他
  • 标签: QT  creater  计算器  

资源简介

基于QT creator 的简单计算器 有ui界面的设计 这是本人在学习QT时自行编写,有什么不正确的地方,还请各位大神指导!

资源截图

代码片段和文件信息


#include “dialog.h“
#include “ui_dialog.h“
#include 
Dialog::Dialog(QWidget *parent) :
    QDialog(parent)
    ui(new Ui::Dialog)
{
    ui->setupUi(this);

    ui->lcdNumber->setNumDigits(10);//设置lcd显示的位数;
    setWindowtitle(“Calculator“);   //设置窗口标题

    //对各个按键进行链接
    connect(ui->pushButton_1SIGNAL(clicked())thisSLOT(button1()));
    connect(ui->pushButton_2SIGNAL(clicked())thisSLOT(button2()));
    connect(ui->pushButton_3SIGNAL(clicked())thisSLOT(button3()));
    connect(ui->pushButton_4SIGNAL(clicked())thisSLOT(button4()));
    connect(ui->pushButton_5SIGNAL(clicked())thisSLOT(button5()));
    connect(ui->pushButton_6SIGNAL(clicked())thisSLOT(button6()));
    connect(ui->pushButton_7SIGNAL(clicked())thisSLOT(button7()));
    connect(ui->pushButton_8SIGNAL(clicked())thisSLOT(button8()));
    connect(ui->pushButton_9SIGNAL(clicked())thisSLOT(button9()));
    connect(ui->pushButton_0SIGNAL(clicked())thisSLOT(button0()));
    connect(ui->pushButton_pointSIGNAL(clicked())thisSLOT(buttonPoint()));

    connect(ui->pushButton_addSIGNAL(clicked())thisSLOT(buttonAdd()));
    connect(ui->pushButton_subSIGNAL(clicked())thisSLOT(buttonSub()));
    connect(ui->pushButton_mulSIGNAL(clicked())thisSLOT(buttonMul()));
    connect(ui->pushButton_divisionSIGNAL(clicked())thisSLOT(buttonDivision()));

    connect(ui->pushButton_equalSIGNAL(clicked())thisSLOT(buttonEqual()));

    connect(ui->pushButton_emptySIGNAL(clicked())thisSLOT(buttonEmpty()));
    connect(ui->pushButton_delSIGNAL(clicked())thisSLOT(buttonDel()));

    connect(ui->pushButton_squareSIGNAL(clicked())thisSLOT(buttonSquare()));
    connect(ui->pushButton_reciprocalSIGNAL(clicked())thisSLOT(buttonReciprocal()));
    connect(ui->pushButton_evolutionSIGNAL(clicked())thisSLOT(buttonEvolution()));
    connect(ui->pushButton_factorialSIGNAL(clicked())thisSLOT(buttonFactorial()));


}

Dialog::~Dialog()
{
    delete ui;
}

//对各个按键进行定义
QString sumsum1;//定义了两个操作数
int aa;         //定义了一个用于判断是那种运算符的整形数;

void Dialog::button1()
{
    sum = sum.append(‘1‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button2()
{
    sum = sum.append(‘2‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button3()
{
    sum = sum.append(‘3‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button4()
{
    sum = sum.append(‘4‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button5()
{
    sum = sum.append(‘5‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button6()
{
    sum = sum.append(‘6‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button7()
{
    sum = sum.append(‘7‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button8()
{
    sum = sum.append(‘8‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button9()
{
    sum = sum.append(‘9‘);
    ui->lcdNumber->display(sum);
}
void Dialog::button0()
{
    sum = sum.append(‘0‘);
    ui->lcdNumber->display(sum);
}
void Dialog::buttonPoint()
{
    sum = sum.append(‘.‘);
    ui->lcdNumb

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       29828  2013-02-21 01:28  computer-build-desktop-Qt_4_8_1___PATH________\dialog.o
     文件        1592  2013-02-20 15:41  computer-build-desktop-Qt_4_8_1___PATH________\main.o
     文件        8325  2013-02-14 06:32  computer-build-desktop-Qt_4_8_1___PATH________\Makefile
     文件       43766  2013-02-21 01:28  computer-build-desktop-Qt_4_8_1___PATH________\computer
     文件       11246  2013-02-21 01:28  computer-build-desktop-Qt_4_8_1___PATH________\ui_dialog.h
     文件        9276  2013-02-20 15:44  computer-build-desktop-Qt_4_8_1___PATH________\moc_dialog.o
     文件        4635  2013-02-20 15:44  computer-build-desktop-Qt_4_8_1___PATH________\moc_dialog.cpp
     文件        5913  2013-02-21 01:28  computer\dialog.ui
     文件           0  2013-02-18 04:58  computer\computer.pro.user.1.3
     文件        5464  2013-02-21 01:17  computer\dialog.cpp
     文件         174  2013-02-12 00:56  computer\main.cpp
     文件         300  2013-02-12 00:56  computer\computer.pro
     文件         776  2013-02-20 15:31  computer\dialog.h
     文件       18571  2013-02-21 01:44  computer\computer.pro.user
     目录           0  2013-02-21 01:28  computer-build-desktop-Qt_4_8_1___PATH________\
     目录           0  2013-02-21 01:44  computer\

评论

共有 条评论