50 lines
850 B
C
50 lines
850 B
C
|
#ifndef MAINWINDOW_H
|
||
|
#define MAINWINDOW_H
|
||
|
|
||
|
#include <QKeyEvent>
|
||
|
#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;
|
||
|
|
||
|
void keyPressEvent(QKeyEvent *e);
|
||
|
|
||
|
//终止运算,清除数据,报错
|
||
|
void abortOperation();
|
||
|
//连接信号和槽
|
||
|
void connectSlots();
|
||
|
//储存运算符
|
||
|
QString pendingOperator;
|
||
|
//储存运算结果
|
||
|
double result;
|
||
|
//标记是否等待一个操作数
|
||
|
bool waitForOperand;
|
||
|
|
||
|
bool isFinished;
|
||
|
|
||
|
private slots:
|
||
|
void on_clearBtn_clicked();
|
||
|
|
||
|
void on_clearAllBtn_clicked();
|
||
|
|
||
|
void on_equalBtn_clicked();
|
||
|
|
||
|
void digitClicked();
|
||
|
|
||
|
void operatorClicked();
|
||
|
void on_actionPaste_triggered();
|
||
|
};
|
||
|
#endif // MAINWINDOW_H
|