My requirement: dynamically create check boxes based on the no.of lines in a text file loaded.
Below is my code :
QVBoxLayout *lay = new QVBoxLayout(this);
for(i=0;i<number_of_commands;i++)
{
QCheckBox *dynamic = new QCheckBox(names[i]);
dynamic->setChecked (true);
lay->addWidget(dynamic);
}
ui->scrollAreaWidgetContents_2->setLayout(lay);
I can see the correct number of check boxes but only first box is named that too with last name (i.e. box1
is named with names[20] and all other boxes are empty)