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

Time for action – Receiving the button-click signal from the form

Open the mainwindow.h file and create a private slots section in the class declaration, then declare the startNewGame() private slot, as shown in the following code:

class MainWindow : public QMainWindow{    Q_OBJECTpublic:    explicit MainWindow(QWidget *parent = nullptr);    ~MainWindow();private slots:    void startNewGame();}

To quickly implement a freshly declared method, we can ask Qt Creator to create the skeleton code for us by positioning the text cursor at the method declaration, pressing  Alt + Enter on the keyboard, and choosing Add definition in tictactoewidget.cpp from the popup.

It also works the other way round. You can write the method body first and then position the ...

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