Method: Use qobject_cast<QLabel*>() to force-convert the sub-control (QLayoutItem) obtained through itemAt(i) to the actual type of the sub-control (such as QLineEdit, QLabel, etc.).
Scenario example:
QLabel *label = qobject_cast<QLabel*>(ui->horizontalLayout_40->itemAt(0)->layout()->itemAt(1)->widget());
label->setStyleSheet("color:rgb(0,255,0)");
label->setText("合格");
You can see that we can get the child control through itemAt. The type is QLayoutItem. If you want to convert it to QLabel, use qobject_cast<QLabel*> to force the QLayoutItem into the QLabel type, so that you can modify the label.