#ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include #include #include #include #include #include"chessitem.h" /* QT的2D绘画 */ const int CHESS_R = 15; const int CHESS_C = 15; const int MAX_X = 50; const int MAX_Y = 50; QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); protected: //实时绘制界面 void paintEvent(QPaintEvent *event); //点击事件 void mousePressEvent(QMouseEvent *event); private: Ui::MainWindow *ui; bool b_black; //定义棋子个数 QVector p_ChessItem; //初始化界面 void InitUI(); //画棋盘 void DraChessBoard(); //画鼠标上的棋子 void DrawHandChess(); //绘制棋盘上的棋子 void DrawChessItem(); void DrawChessAtPoint(QPainter &painter,QPoint &point); //判断五子是否连接 int CountNearItem(ChessItem item,QPoint pt); }; #endif // MAINWINDOW_H