What just happened?

In the last exercise, we defined the base architecture for our solution. We can see that there are three classes involved: ChessView acting as the user interface, ChessAlgorithm for driving the actual game, and ChessBoard as a data structure shared between the view and the engine. The algorithm will be responsible for setting up the board (through setupBoard()), making moves, checking win conditions, and so on. The view will be rendering the current state of the board and will signal user interaction to the underlying logic.

Most of the code is self-explanatory. You can see in the ChessView::setBoard() method that we are disconnecting all signals from an old board object, attaching the new one (we will come back to connecting ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition 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.