What just happened?

We created a new private slot in the MainWindow class and connected the clicked() signal of the Start new game button to the slot. When the user clicks on the button, Qt will call our slot, and the code we wrote inside it gets executed.

Ensure that you put any operations with the form elements after the setupUi() call. This function creates the elements, so ui->startNewGame will simply be uninitialized before setupUi() is called, and attempting to use it will result in undefined behavior.

qDebug() << ... is a convenient way to print debug information to the stderr (standard error output) of the application process. It's quite similar to the std::cerr << ... method available in the standard library, but it separates supplied ...

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.