O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required