Getting text values from dynamically created Qline edits in Qt c++
I have created a set of Qline edits successfully and assigned each line edit an Object name but unfortunately when I try to read and get them into a QStringList I get an error stating
"Textbox was not declared in this scope"
my code is as follows!
f1 = new QFrame();
f2 = new QFrame();
f3 = new QFrame();
a= new QLabel(f1);
QString oName= QString::number(i); b->setObjectName("Textbox"+oName); ui->verticalLayout->addWidget(f1); ui->verticalLayout_2->addWidget(f2); ui->verticalLayout_3->addWidget(f3); a->setText(newList[i]);
and from the button click event I won't to get each text in the dynamically created QLine edits!
QString oName= QString::number(i);
Here getlist and newlist are QStirngLists are already defined as public! How can I correct this?
That part is wrong. The objectName property is a property of a C++ object. It is not name of the C++ variable, and not part of ui.
Side note: in each step of your first for loop, you create 3 new QLineEdits, but you only change the objectName of one of them (b). The rest remains unnamed.