bool MainWindow::CheckFormValid(){ QWidget *w = this->findChild< QWidget * >("groupBox"); QList< QLineEdit * > l1 = w->findChildren< QLineEdit * >(); QList< QLabel * > l2 = w->findChildren< QLabel * >(); for (int i = 0; i < l1.size(); i++) { l2[i]->setStyleSheet("color: black"); if (l1[i]->text() == "") { qDebug()<<i<<"isEmpty"; /* if QMessageBox::Yes == */QMessageBox(QMessageBox::Information, "Test", "Не заполнено поле: " + l2[i]->text(), QMessageBox::Ok).exec(); l1[i]->setFocus(); l2[i]->setStyleSheet("color: red"); ui->pushButton->setChecked(false); return false; break; } else l2[i]->setStyleSheet("color: black"); }return true;}
if (l1[i]->text() == "")
l1[i]
l2[i]
C++ (Qt)for (int i = 0; i < maxEdit; ++i) { QString index = QString::number(i + 1); QLineEdit * edit = group->findChild<QLineEdit *> ("edit_" + index); Q_ASSERT(edit); if (edit->text().size() == 0) { QLineEdit * lab = group->findChild<QLabel *> ("label_" + index); Q_ASSERT(lab);// QMessageBox }}