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++)
{
ui
->boxtoinput
->addItem
(QString::number(i
));
}
int i;
for(i=1;i<=20;i++)
{
QString boxtoinput = "in_" + QString::number(i);
ui->boxtoinput->addItem(QString::number(i));
}
To copy to clipboard, switch view to plain text mode
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);
QList<QListWidget *> allPButtons = this->findChildren<QListWidget *>(boxtoinput);
To copy to clipboard, switch view to plain text mode
that returns
QListWidget(0x287daf0, name = "in_5")
To copy to clipboard, switch view to plain text mode
Now with that how does one add add an item to it
Regards
Bookmarks