MyCalculator.h
#pragma once
#include <QtWidgets/QMainWindow>
#include <QStack>
#include <QString>
#include "ui_MyCalculator.h"
class MyCalculator : public QMainWindow
{
Q_OBJECT
public:
MyCalculator(QWidget *parent = Q_NULLPTR);
private slots:
void on_number_Button_clicked();
void on_action_Button_clicked();
void on_comma_Button_clicked();
void on_action_Button_c_clicked();
void on_action_Button_d_clicked();
void on_action_Button_e_clicked();
private:
Ui::MyCalculatorClass ui;
};
MyCalculator.main
#include "MyCalculator.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyCalculator w;
w.show();
return a.exec();
}
MyCalculator.cpp
#include "MyCalculator.h"
#include<iostream>
using namespace std;
#include<stack>
#include<vector>
#include<cstdlib>
#include<limits.h>
MyCalculator::MyCalculator(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
setWindowTitle(QStringLiteral("计算器"));
ui.textBrowser->setFontPointSize(28);
connect(ui.pushButton0, SIGNAL(clicked()), this, SLOT(on_number_Button_clicked()));
connect(ui.pushButton1, SIGNAL(clicked()), this, SLOT(on_number_Button_clicked()));
connect(ui.pushButton2, SIGNAL(clicked()), this, SLOT(on_number_Button_clicked()));
connect(ui.pushButton3, SIGNAL(clicked()), this, SLOT(on_number_Button_clicked()));
connect(ui.pushButton4, SIGNAL(clicked()), this, SLOT(on_number_Button_clicked()));
connect(ui.pushButton5, SIGNAL(clicked()), this, SLOT(on_number_Button_clicked()));
connect(ui.pushButton6, SIGNAL(clicked()), this, SLOT(on_number_Button_clicked()));
connect(ui.pushButton7, SIGNAL(clicked()), this<