Time for action – Adding widgets to the form

Locate the Label item in the toolbox (it's in the Display Widgets category) and drag it to our form. Use the property editor to set the objectName property of the label to player1Name. objectName is a unique identifier of a form item. The object name is used as the name of the public field in the Ui::MainWindow class, so the label will be available as ui->player1Name in the MainWindow class (and will have a QLabel * type). Then, locate the text property in the property editor (it will be in the QLabel group, as it is the class that introduces the property) and set it to Player 1. You will see that the text in the central area will be updated accordingly. Add another label, set its objectName to ...

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.