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?

QWidget (and, by extension, any widget class) has a font property that determines the properties of the font this widget uses. This property has the QFont type. We can't just write label->font()->setBold(isBold);, because font() returns a const reference, so we have to make a copy of the QFont object. That copy has no connection to the label, so we need to call label->setFont(f) to apply our changes. To avoid repetition of this procedure, we created a helper function, called setLabelBold.

The last thing that needs to be done is to handle the situation when the game ends. Connect the gameOver() signal from the board to a new slot in the main window class. Implement the slot as follows:

void MainWindow::handleGameOver(TicTacToeWidget::Player ...

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