49 lines
903 B
C++
49 lines
903 B
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include <QMainWindow>
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
namespace Ui { class MainWindow; }
|
|
QT_END_NAMESPACE
|
|
|
|
class MainWindow : public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MainWindow(QWidget *parent = nullptr);
|
|
~MainWindow();
|
|
|
|
private:
|
|
Ui::MainWindow *ui;
|
|
|
|
bool calculate(double operand, QString pendingOperator);
|
|
//终止运算,清除数据,报错
|
|
void abortOperation();
|
|
//连接信号和槽
|
|
void connectSlots();
|
|
//储存运算符
|
|
QString pendingOperator;
|
|
//储存运算结果
|
|
double result;
|
|
//标记是否等待一个操作数
|
|
bool waitForOperand;
|
|
|
|
private slots:
|
|
void on_clearBtn_clicked();
|
|
|
|
void on_clearAllBtn_clicked();
|
|
|
|
void on_equalBtn_clicked();
|
|
|
|
void digitClicked();
|
|
|
|
void on_signBtn_clicked();
|
|
|
|
void operatorClicked();
|
|
|
|
void on_pointBtn_clicked();
|
|
|
|
};
|
|
#endif // MAINWINDOW_H
|