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*); ...

Get Game Programming Using Qt now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.