Time for action – developing the game architecture
Create a new
Qt Widgets Application project. After the project infrastructure is ready, choose New File or Project from the File menu and choose to create a C++ Class. Call the new class ChessBoard
and set QObject
as its base class. Repeat the process to create a GameAlgorithm
class derived from QObject
and another one called ChessView
but, this time, choose QWidget
as the base class. You should end up with a file named main.cpp
and four classes—MainWindow
, ChessView
, ChessBoard
, and ChessAlgorithm
.
Now navigate to the header file for ChessAlgorithm
and add the following methods to the class:
public: ChessBoard* board() const; public slots: virtual void newGame(); signals: void boardChanged(ChessBoard*); protected: virtual void setupBoard(); void setBoard(ChessBoard *board);
Also, add a private m_board
field of type ChessBoard*
. Remember to either include chessboard.h
or forward-declare the ChessBoard
class. Implement board()
as...