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?

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

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