Time for action – the logic of the dialog

Now, it is time to make our game settings dialog work. Earlier, we declared a signal-slot connection but now the slot itself needs to be implemented.

Open the form class generated by Creator. If you're still in the Design mode, you can quickly jump to the respective form class file using the Shift + F4 keyboard shortcut. Create a public slots section of the class and declare a void updateOKButtonState() slot. Open the refactorization menu (Alt + Enter) and ask Creator to create the skeleton implementation of the slot for you. Fill the function body with the following code:

void ConfigurationDialog::updateOKButtonState() { bool pl1NameEmpty = ui->player1Name->text().isEmpty(); bool pl2NameEmpty = ui->player2Name->text().isEmpty(); ...

Get Game Programming Using Qt 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.