ShapeShiftme
17th May 2012, 03:48
Good Day All
I have 20 lis boxes in my ui.
named:
in_1
in_2
in_3
....
in_20
now im trying to add items dynamically this is what i would like to do but its not working
int i;
for(i=1;i<=20;i++)
{
QString boxtoinput = "in_" + QString::number(i);
ui->boxtoinput->addItem(QString::number(i));
}
The hope would be the above code will write the number of the box into each box.
Any ideas of how i would do this
i know i could write an if statement for each box but then i can genrate the forms dynamically.
Regards
Added after 12 minutes:
Another idea i had would be to loop through using this
QList<QListWidget *> allPButtons = this->findChildren<QListWidget *>(boxtoinput);
that returns
QListWidget(0x287daf0, name = "in_5")
Now with that how does one add add an item to it
Regards
I have 20 lis boxes in my ui.
named:
in_1
in_2
in_3
....
in_20
now im trying to add items dynamically this is what i would like to do but its not working
int i;
for(i=1;i<=20;i++)
{
QString boxtoinput = "in_" + QString::number(i);
ui->boxtoinput->addItem(QString::number(i));
}
The hope would be the above code will write the number of the box into each box.
Any ideas of how i would do this
i know i could write an if statement for each box but then i can genrate the forms dynamically.
Regards
Added after 12 minutes:
Another idea i had would be to loop through using this
QList<QListWidget *> allPButtons = this->findChildren<QListWidget *>(boxtoinput);
that returns
QListWidget(0x287daf0, name = "in_5")
Now with that how does one add add an item to it
Regards