QLabel* label = new QLabel("Hello World"); label->setObjectName("myLabel");
QLabel* label = ui->myLabel; // assuming myLabel is the object name of a QLabel on a form label->setObjectName("newLabel");
QListThis code finds all QLabel widgets that are children of a central widget of a UI form and sets their object name to "label". The Qt library provides the QLabel class and its setObjectName method.labels = ui->centralWidget->findChildren (); foreach (QLabel* label, labels) { label->setObjectName("label"); }