资源简介

Qt creator 设计的简易计算器工程源码包,标准型,功能全面。

资源截图

代码片段和文件信息

#include 
#include ript>
#include 

#include “calculator.h“

Calculator::Calculator(QWidget *parent)
    : QDialog(parent)
{
    sumInMemory = 0.0;
    sumSoFar = 0.0;
    factorSoFar = 0.0;
    waitingForOperand = true;

    display = new QLineEdit(“0“);
    display->setReadOnly(true);
    display->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

    QFont font = display->font();
    font.setPointSize(font.pointSize() + 8);
    display->setFont(font);

    for (int i = 0; i < NumDigitButtons; ++i) {
        digitButtons[i] = createButton(QString::number(i)
                                       SLOT(digitClicked()));
    }

    pointButton = createButton(tr(“.“) SLOT(pointClicked()));
    changeSignButton = createButton(tr(“\261“)
                                    SLOT(changeSignClicked()));

    backspaceButton = createButton(tr(“Backspace“)
                                   SLOT(backspaceClicked()));
    clearButton = createButton(tr(“Clear“) SLOT(clear()));
    clearAllButton = createButton(tr(“Clear All“) SLOT(clearAll()));

    clearMemoryButton = createButton(tr(“MC“) SLOT(clearMemory()));
    readMemoryButton = createButton(tr(“MR“) SLOT(readMemory()));
    setMemoryButton = createButton(tr(“MS“) SLOT(setMemory()));
    addToMemoryButton = createButton(tr(“M+“) SLOT(addToMemory()));

    divisionButton = createButton(tr(“\367“)
                             SLOT(multiplicativeOperatorClicked()));
    timesButton = createButton(tr(“\327“)
                               SLOT(multiplicativeOperatorClicked()));
    minusButton = createButton(tr(“-“)
                               SLOT(additiveOperatorClicked()));
    plusButton = createButton(tr(“+“)
                              SLOT(additiveOperatorClicked()));

    squareRootButton = createButton(tr(“Sqrt“)
                                    SLOT(unaryOperatorClicked()));
    powerButton = createButton(tr(“x\262“)
                               SLOT(unaryOperatorClicked()));
    reciprocalButton = createButton(tr(“1/x“)
                                    SLOT(unaryOperatorClicked()));
    equalButton = createButton(tr(“=“) SLOT(equalClicked()));

    createCustomButtons();

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->setContentsMargins(8 8 8 8);
    mainLayout->setHorizontalSpacing(5);
    mainLayout->setVerticalSpacing(5);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);

    mainLayout->addWidget(display 0 0 1 6);
    mainLayout->addWidget(backspaceButton 1 0 1 2);
    mainLayout->addWidget(clearButton 1 2 1 2);
    mainLayout->addWidget(clearAllButton 1 4 1 2);

    mainLayout->addWidget(clearMemoryButton 2 0);
    mainLayout->addWidget(readMemoryButton 3 0);
    mainLayout->addWidget(setMemoryButton 4 0);
    mainLayout->addWidget(addToMemoryButton 5 0);

    for (int i = 1; i < NumDigitButtons; ++i) {
        int row = ((9 - i) / 3) + 2;
        int column = ((i - 1) % 3) + 1;
        main

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

     文件      11611  2008-01-09 08:43  calculator\calculator.cpp

     文件       1848  2008-01-09 08:43  calculator\calculator.h

     文件        130  2008-01-09 08:43  calculator\calculator.pro

     文件      23780  2011-12-20 00:25  calculator\calculator.pro.user

     文件        182  2008-01-09 08:43  calculator\main.cpp

     文件         18  2008-01-09 08:43  calculator\scripts\cube.js

     文件        152  2008-01-09 08:43  calculator\scripts\factorial.js

     文件         31  2008-01-09 08:43  calculator\scripts\pi.js

     目录          0  2011-12-19 18:17  calculator\scripts

     目录          0  2011-12-19 18:47  calculator

----------- ---------  ---------- -----  ----

                37752                    10


评论

共有 条评论